LOCAL void Meter_OnDraw(HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight) /***********************************************************************/ { RECT rSrcArea, rDstArea, rControlArea; POINT ptDst; PDIB pdibSrc, pdibDst, pdibSrc2, pdibTmp; UINT id; LPOFFSCREEN lpOffScreen; LPSCENE lpScene; HDC hWinGDC; HPALETTE hLoadPal; lpScene = CScene::GetScene( GetParent(hWindow) ); if (!lpScene) return; LPMETERCONTINFO lpInfo; if (!(lpInfo = (LPMETERCONTINFO)GetWindowLong(hWindow, GWL_DATAPTR) )) return; rSrcArea = * lpRect; rDstArea = * lpRect; rControlArea = * lpRect; lpOffScreen = lpScene->GetOffScreen(); if (lpOffScreen) { MapWindowPoints(hWindow, GetParent(hWindow), (LPPOINT)& rDstArea, 2); if (!(pdibSrc = lpOffScreen->GetReadOnlyDIB() ) ) return; if (!(pdibDst = lpOffScreen->GetWritableDIB() ) ) return; hWinGDC = lpOffScreen->GetDC(); hLoadPal = GetApp()->m_hPal; } else { return; } RECT rClient; GetClientRect(hWindow, & rClient); MapWindowPoints(hWindow, GetParent(hWindow), (LPPOINT)& rClient, 2 ); // Get the control style DWORD dwStyle = GetWindowStyle(hWindow); BOOL bVert = (dwStyle & MC_VERT) ? TRUE : FALSE ; // Get the control id if (!(id = GetWindowWord(hWindow, GWW_ICONID) ) ) id = GET_WINDOW_ID(hWindow); // Refresh the background, // compressed DIBs must use GDI copying (lose transparency ability) if (pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8) { pdibSrc->DCBlt(hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top ); } else { pdibSrc->DibBlt(pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, NO /*bTransparent*/ ); } // Load the resource if (pdibSrc = CDib::LoadDibFromResource(GetWindowInstance(hWindow), MAKEINTRESOURCE(id), hLoadPal, (dwStyle & BS_MASK) != 0) ) { if (pdibSrc2 = CDib::LoadDibFromResource(GetWindowInstance(hWindow), MAKEINTRESOURCE(id + 1), hLoadPal, (dwStyle & BS_MASK) != 0) ) { int iBitmapWidth = pdibSrc->GetWidth(); int iBitmapHeight = pdibSrc->GetHeight(); rSrcArea.left = 0; rSrcArea.top = 0; rSrcArea.right = rSrcArea.left + iBitmapWidth; rSrcArea.bottom = rSrcArea.top + iBitmapHeight; rDstArea = rClient; rDstArea.right = rDstArea.left + iBitmapWidth; rDstArea.bottom = rDstArea.top + iBitmapHeight; // Get the position width int iPosWidth; if (bVert) { iPosWidth = (int)( (float)iBitmapHeight * ((float)lpInfo->lPosition / ((float)lpInfo->Max - (float)lpInfo->Min))); iPosWidth = iBitmapHeight - iPosWidth; } else { iPosWidth = (int)( (float)iBitmapWidth * ((float)lpInfo->lPosition / ((float)lpInfo->Max - (float)lpInfo->Min))); } // compressed DIBs must use GDI copying (lose transparency ability) if (pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8 ) { pdibSrc->DCBlt(hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top); } else { RGBTRIPLE rgb; LPRGBTRIPLE lpRGB = NULL; if (dwStyle & BS_MASK) { STRING szColor; GetWindowText(hWindow, szColor, sizeof(szColor)); AsciiRGB(szColor, & rgb); if (fHighlight) { // this relies on the fact that AsciiRGB replaces commas // with NULL terminators LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red lp += lstrlen(lp) + 1; // passed green lp += lstrlen(lp) + 1; // passed blue to higlight color AsciiRGB(lp, & rgb); } lpRGB = & rgb; } // Render the first bitmap pdibTmp = pdibSrc; pdibTmp->DibBlt(pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top, FALSE /*bTransparent*/, lpRGB); } // Adjust the source and dest rect's and render the 2nd bitmap if (bVert) { //rDstArea.top = rDstArea.top;// iPosWidth; rDstArea.bottom = rDstArea.top + iPosWidth; //rSrcArea.top = rSrcArea.bottom - iPosWidth; rSrcArea.bottom = iPosWidth; } else { rDstArea.right = rDstArea.left + iPosWidth; rSrcArea.right = rSrcArea.left + iPosWidth; } // compressed DIBs must use GDI copying (lose transparency ability) if (pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8 ) { pdibSrc->DCBlt(hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top); } else { RGBTRIPLE rgb; LPRGBTRIPLE lpRGB = NULL; if (dwStyle & BS_MASK) { STRING szColor; GetWindowText(hWindow, szColor, sizeof(szColor)); AsciiRGB(szColor, & rgb); if (fHighlight) { // this relies on the fact that AsciiRGB replaces commas // with NULL terminators LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red lp += lstrlen(lp) + 1; // passed green lp += lstrlen(lp) + 1; // passed blue to higlight color AsciiRGB(lp, & rgb); } lpRGB = & rgb; } // Render the first bitmap pdibTmp = pdibSrc2; pdibTmp->DibBlt(pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top, FALSE /*bTransparent*/, lpRGB); } } delete pdibSrc; delete pdibSrc2; } ptDst.x = rControlArea.left; ptDst.y = rControlArea.top; if (lpOffScreen) { lpOffScreen->DrawRect(hDC, & rClient, & ptDst); } }
DWORD __far __pascal WndData( HWND hWnd, WNDDATAMSG Msg, DWORD dwParam, void __far * fpDataBuffer ) { RECT __far * fpRect; FPWNDDATA fpWndData; HWNDDATA hWndData; DWORD dwReturn; switch( Msg ) { /******************* CHILDWNDDATA structure messages. *******************/ /* Am I painting the window currently. */ case WDM_SETAMPAINTING: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->ChildWndData.bAmPainting = ( BOOL ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETAMPAINTING: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->ChildWndData.bAmPainting; GlobalUnlock( hWndData ); return( dwReturn ); } /* The screen position of a hotspot. */ case WDM_SETHOTSPOTPOS: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpRect = ( RECT __far * ) fpDataBuffer; fpWndData->ChildWndData.HotSpotPosRec = *fpRect; GlobalUnlock( hWndData ); return 0; } case WDM_GETHOTSPOTPOS: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpRect = ( RECT __far * ) fpDataBuffer; *fpRect = fpWndData->ChildWndData.HotSpotPosRec; GlobalUnlock( hWndData ); return( dwReturn ); } /* The display data for window. */ case WDM_SETDISPLAYINFO: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->ChildWndData.hDisplayInfo = ( HGLOBAL ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETDISPLAYINFO: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->ChildWndData.hDisplayInfo; GlobalUnlock( hWndData ); return( dwReturn ); } /* Handle to the window that keeps the data. */ case WDM_SETDATAHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->ChildWndData.hDataWnd = ( HWND ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETDATAHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->ChildWndData.hDataWnd; GlobalUnlock( hWndData ); return( dwReturn ); } /* Handle of the window's parent window. */ case WDM_SETPARENTHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->ChildWndData.hParentWnd = ( HWND ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETPARENTHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->ChildWndData.hParentWnd; GlobalUnlock( hWndData ); return( dwReturn ); } /* Handle to the non-scrollable topic window. */ case WDM_SETNOSCROLLHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->ChildWndData.hNoScrollWnd = ( HWND ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETNOSCROLLHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->ChildWndData.hNoScrollWnd; GlobalUnlock( hWndData ); return( dwReturn ); } /* Position of window in client area. */ case WDM_SETCLIENTPOS: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpRect = ( RECT __far * ) fpDataBuffer; fpWndData->ChildWndData.ClientPosRect = *fpRect; GlobalUnlock( hWndData ); return 0; } case WDM_GETCLIENTPOS: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpRect = ( RECT __far * ) fpDataBuffer; *fpRect = fpWndData->ChildWndData.ClientPosRect; GlobalUnlock( hWndData ); return( dwReturn ); } /******************* MAINWNDDATA structure messages. *******************/ /* Handle to accelerator support system. */ case WDM_SETACCELSYS: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.hAccelSys = ( HACCELSYS ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETACCELSYS: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->MainWndData.hAccelSys; GlobalUnlock( hWndData ); return( dwReturn ); } /* Handle to the window that keeps the data. */ case WDM_SETMAINDATAHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.hDataWnd = ( HWND ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETMAINDATAHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->MainWndData.hDataWnd; GlobalUnlock( hWndData ); return( dwReturn ); } /* Is the Search dialog already being displayed. */ case WDM_SETSEARCHDLGDISPLAYED: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.bSearchDlgDisplayed = ( BOOL ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETSEARCHDLGDISPLAYED: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->MainWndData.bSearchDlgDisplayed; GlobalUnlock( hWndData ); return( dwReturn ); } /* Topic data for main topic window. */ case WDM_SETMAINTOPICDATA: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.hTopicData = ( HTOPICDATA ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETMAINTOPICDATA: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->MainWndData.hTopicData; GlobalUnlock( hWndData ); return( dwReturn ); } /* Active secondary window list. */ case WDM_SETSECWNDDATA: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.hSecWndList = ( HGLOBAL ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETSECWNDDATA: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->MainWndData.hSecWndList; GlobalUnlock( hWndData ); return( dwReturn ); } /* Handle to the "Back" button data. */ case WDM_SETBACKDATA: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.hBackBtnData = ( HGLOBAL ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETBACKDATA: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->MainWndData.hBackBtnData; GlobalUnlock( hWndData ); return( dwReturn ); } /* Browse next topic offset. */ case WDM_SETBROWSENEXTDATA: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.dwNextTopicCharOffset = ( long int ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETBROWSENEXTDATA: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = ( long int ) fpWndData->MainWndData.dwNextTopicCharOffset; GlobalUnlock( hWndData ); return( dwReturn ); } /* Browse prev. topic offset. */ case WDM_SETBROWSEPREVDATA: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.dwPrevTopicCharOffset = ( long int ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETBROWSEPREVDATA: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = ( long int ) fpWndData->MainWndData.dwPrevTopicCharOffset; GlobalUnlock( hWndData ); return( dwReturn ); } /* Help file/topic information buffer. */ case WDM_SETFILEBUFFER: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.hHelpFileBuffer = ( HGLOBAL ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETFILEBUFFER: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->MainWndData.hHelpFileBuffer; GlobalUnlock( hWndData ); return( dwReturn ); } /* History window's HWND. */ case WDM_SETHISTORYHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.hHistoryWnd = ( HWND ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETHISTORYHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->MainWndData.hHistoryWnd; GlobalUnlock( hWndData ); return( dwReturn ); } /* Main topic window's HWND. */ case WDM_SETMAINTOPICHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.hTopicWnd = ( HWND ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETMAINTOPICHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->MainWndData.hTopicWnd; GlobalUnlock( hWndData ); return( dwReturn ); } /* Button bar window's HWND. */ case WDM_SETBUTTONBARHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.hButtonBarWnd = ( HWND ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETBUTTONBARHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->MainWndData.hButtonBarWnd; GlobalUnlock( hWndData ); return( dwReturn ); } /* Window to notify when quitting. */ case WDM_SETQUITHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.hQuitWnd = ( HWND ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETQUITHWND: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->MainWndData.hQuitWnd; GlobalUnlock( hWndData ); return( dwReturn ); } /* Macro engine instance handle. */ case WDM_SETMACROENGINE: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); fpWndData->MainWndData.hMacroEngine = ( HMACROENGINE ) dwParam; GlobalUnlock( hWndData ); return 0; } case WDM_GETMACROENGINE: { hWndData = (HWNDDATA) GetWindowWord( hWnd, 0 ); fpWndData = ( FPWNDDATA ) GlobalLock( hWndData ); dwReturn = (DWORD) fpWndData->MainWndData.hMacroEngine; GlobalUnlock( hWndData ); return( dwReturn ); } } /* If message doesn't return a value - return 0. */ return 0; }
/* * Function: Main routine called on program invocation. * * Parameters: * hinstance - the current instance * * hprevinstance - previous instance if one exists or NULL. * * cmdline - the command line string passed by Windows. * * ncmdshow - show flag to indicate wheather to come up minimized * or not. * * Returns: TRUE if initialized sucessfully, false otherwise. */ int PASCAL WinMain(HINSTANCE hinst, HINSTANCE hprevinstance, LPSTR cmdline, int ncmdshow) { DLGPROC dlgproc; HWND hwnd; HACCEL haccel; MSG msg; char *p; char buf[MAX_K_NAME_SZ + 9]; char name[MAX_K_NAME_SZ]; strcpy(buf, cmdline); action = LOGIN_AND_RUN; name[0] = 0; p = strtok(buf, " ,"); while (p != NULL) { if (_stricmp(p, "/exit") == 0) action = LOGIN_AND_EXIT; else if (_stricmp(p, "/minimize") == 0) action = LOGIN_AND_MINIMIZE; else strcpy(name, p); p = strtok(NULL, " ,"); } dlgncmdshow = ncmdshow; hinstance = hinst; #ifndef _WIN32 /* * If a previous instance of this application exits, bring it * to the front and exit. * * This code is not compiled for WIN32, since hprevinstance will always * be NULL. */ if (hprevinstance != NULL) { hwnd = FindWindow(KWIN_DIALOG_CLASS, NULL); if (IsWindow(hwnd) && IsWindowVisible(hwnd)) { if (GetWindowWord(hwnd, GWW_HINSTANCE) == hprevinstance) { if (name[0]) SendMessage(hwnd, WM_KWIN_SETNAME, 0, (LONG)name); ShowWindow(hwnd, ncmdshow); SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); return FALSE; } } } if (hprevinstance == NULL) #endif /* _WIN32 */ if (!init_application(hinstance)) return FALSE; if (!init_instance(hinstance, ncmdshow)) return FALSE; #ifdef _WIN32 dlgproc = kwin_dlg_proc; #else dlgproc = (FARPROC)MakeProcInstance(kwin_dlg_proc, hinstance); assert(dlgproc != NULL); if (dlgproc == NULL) return 1; #endif hwnd = CreateDialogParam(hinstance, MAKEINTRESOURCE(ID_KWIN), HWND_DESKTOP, dlgproc, (LONG)name); assert(hwnd != NULL); if (hwnd == NULL) return 1; haccel = LoadAccelerators(hinstance, MAKEINTRESOURCE(IDA_KWIN)); assert(hwnd != NULL); while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(hwnd, haccel, &msg) && !IsDialogMessage(hwnd, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } DestroyWindow(hwnd); #ifndef _WIN32 FreeProcInstance((FARPROC)dlgproc); #endif cns_save_registry(); return 0; }
LOCAL void Story_OnDraw(HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight) /***********************************************************************/ { BOOL bHasFocus, bSelected, bDown; DWORD dwStyle; RECT rSrcArea, rDstArea; POINT ptDst; PDIB pdibSrc, pdibDst, pDib; LPOFFSCREEN lpOffScreen; PTOON pToon; LPSCENE lpScene; PSTORY pStory; RGBQUAD rgbQuad[256]; BITMAPINFOHEADER bmi; LPTR lp; HDC hWinGDC; HPALETTE hWinGPal = NULL, hDisplayPal = NULL, hOldPal; if (IsRectEmpty(lpRect)) return; pStory = GetStory(hWindow); if (!pStory) return; if (!pStory->m_pDib) return; lpScene = CScene::GetScene(GetParent(hWindow)); if (!lpScene) return; rSrcArea = *lpRect; rDstArea = *lpRect; bSelected = GetWindowWord(hWindow, GWW_STATE ); dwStyle = GetWindowLong( hWindow, GWL_STYLE ); bHasFocus = ( GetFocus() == hWindow ); bDown = ( bSelected || (bTrack && bInRect && bHasFocus) ); lpOffScreen = lpScene->GetOffScreen(); if (lpOffScreen) { MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rDstArea, 2 ); if ( !(pdibSrc = lpOffScreen->GetReadOnlyDIB()) ) return; if ( !(pdibDst = lpOffScreen->GetWritableDIB()) ) return; hWinGDC = lpOffScreen->GetDC(); hWinGPal = hDisplayPal = GetApp()->m_hPal; } else { // fix HWND hToon = FindClassDescendent(GetParent(hWindow), "toon"); if (!hToon) return; pToon = GetToon(hToon); if (!pToon) return; MapWindowPoints( hWindow, pToon->GetWindow(), (LPPOINT)&rDstArea, 2 ); pdibSrc = pToon->GetStageDib(); lp = ToonGetDIBPointer(pToon->GetToonHandle(), &bmi); ToonGetColors(pToon->GetToonHandle(), 0, 256, rgbQuad); bmi.biClrUsed = 256; pdibDst = new CDib(&bmi, rgbQuad, lp); if (!pdibDst) return; hWinGDC = ToonDC(pToon->GetToonHandle()); // to make sure we don't change the system palette hDisplayPal = CopySystemPalette(); // to match WinG dib hWinGPal = CreateCustomPalette(rgbQuad, 256); } if (!pStory->m_fMappedToPalette && ((dwStyle & BS_MASK) == 0)) { pStory->m_pDib->MapToPalette(hWinGPal); pStory->m_fMappedToPalette = TRUE; } // Copy source dib so we can twiddle its bits pDib = new CDib(); if (!pDib) { if (!lpOffScreen && hDisplayPal) DeleteObject(hDisplayPal); if (!lpOffScreen && hWinGPal) DeleteObject(hWinGPal); return; } if (!pDib->Create(pStory->m_pDib->GetBitCount(), lpRect->right-lpRect->left, lpRect->bottom-lpRect->top)) { delete pDib; if (!lpOffScreen && hDisplayPal) DeleteObject(hDisplayPal); if (!lpOffScreen && hWinGPal) DeleteObject(hWinGPal); return; } pDib->CopyColorTable(pStory->m_pDib); // draw in source bitmap pStory->m_pDib->DibBlt( pDib, 0, 0, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top, NO /*bTransparent*/ ); if ( pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8) { // compressed DIBs must use GDI copying (lose transparency ability) pdibSrc->DCBlt( hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top ); } else { pdibSrc->DibBlt( pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, NO /*bTransparent*/ ); } if ( pDib->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8 ) { // compressed DIBs must use GDI copying (lose transparency ability) pDib->DCBlt( hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top ); } else { RGBTRIPLE rgb; LPRGBTRIPLE lpRGB = NULL; if (dwStyle & BS_MASK) { STRING szColor; GetWindowText(hWindow, szColor, sizeof(szColor)); AsciiRGB( szColor, &rgb ); if (fHighlight) { // this relies on the fact that AsciiRGB replaces commas // with NULL terminators LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red lp += lstrlen(lp) + 1; // passed green lp += lstrlen(lp) + 1; // passed blue to higlight color AsciiRGB(lp, &rgb); rgb.rgbtRed = rgb.rgbtGreen = 0; rgb.rgbtBlue = 255; } else rgb.rgbtRed = rgb.rgbtGreen = rgb.rgbtBlue = 0; lpRGB = &rgb; } else { BYTE bTrans = *pStory->m_pDib->GetXY(0, 0); LPTR lpColor = pStory->m_pDib->GetXY(1, 0); LPTR lpHighlight = pStory->m_pDib->GetXY(2, 0); BYTE bColor = *lpColor; BYTE bHighlight = *lpHighlight; // if highlight color is the transparent color then // we are hiding and showing highlighted area // if not, then we are changing the color of highlighted area if (bHighlight == bTrans) { // we need to strip off highlight info if we are not // highlighted if (!fHighlight && (bColor != bTrans)) { HPTR hp = pDib->GetPtr(); DWORD dwSize = pDib->GetSizeImage(); while (dwSize) { if (*hp != bColor) *hp = bTrans; ++hp; --dwSize; } } } else { // we need to change the color if we are highlighted if (fHighlight && (bColor != bHighlight) && (bColor != bTrans)) { HPTR hp = pDib->GetPtr(); DWORD dwSize = pDib->GetSizeImage(); while (dwSize) { if (*hp == bColor) *hp = bHighlight; ++hp; --dwSize; } } } } pDib->DibBlt( pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, 0, 0, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top, YES/*bTransparent*/, lpRGB, NULL, hWinGPal ); } delete pDib; ptDst.x = rSrcArea.left; ptDst.y = rSrcArea.top; if (lpOffScreen) { lpOffScreen->DrawRect( hDC, &rDstArea, &ptDst ); } else { //if (hDisplayPal) //{ // hOldPal = SelectPalette(hDC, hDisplayPal, FALSE); // RealizePalette(hDC); //} //pdibDst->DCBlt( hDC, // ptDst.x, ptDst.y, // rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, // rDstArea.left, rDstArea.top, // rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top ); WinGStretchBlt( hDC, ptDst.x, ptDst.y, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top ); //if (hDisplayPal) //{ // SelectPalette(hDC, hOldPal, TRUE); // DeleteObject(hDisplayPal); //} if (hWinGPal) DeleteObject(hWinGPal); } }
LRESULT WINAPI DefDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) { DLGPROC f; LRESULT rc; HBRUSH hBrush; HFONT hFont; RECT rcClient; HWND hWndChild, hWndFocus; DWORD dwStyle; WORD wTmp; HCLASS32 hDialog32; APISTR((LF_APICALL,"DefDlgProc(HWND=%x,UINT=%x,WPARAM=%x,LPARAM=%lx)\n", hDlg,iMessage,wParam,lParam)); if (!IsWindow(hDlg)) { APISTR((LF_APIFAIL,"DefDlgProc: returns LRESULT 0\n")); return 0L; } if (iMessage == WM_CONVERT) { if (!lpDialogBinToNat) { hDialog32 = FindClass(TWIN_DIALOGCLASS,(HINSTANCE)0); lpDialogBinToNat = (WNDPROC)GetClassHandleLong( hDialog32,GCL_BINTONAT); } if (lpDialogBinToNat) { rc = lpDialogBinToNat(hDlg,iMessage,wParam,lParam); APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc)); return rc; } else { APISTR((LF_APIFAIL,"DefDlgProc: returns LRESULT 0\n")); return (LRESULT)0; } } if ( (f = (DLGPROC) GetWindowLong(hDlg,DWL_DLGPROC)) ) { rc = CallWindowProc( #ifdef STRICT (WNDPROC)f, #else (FARPROC)f, #endif hDlg,iMessage,wParam,lParam); } else rc = 0L; if (!IsWindow(hDlg)) { /* dialog has been destroyed in the callback */ APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc)); return rc; } if(LOWORD(rc) == 0) { switch(iMessage) { case WM_ERASEBKGND: GetClientRect(hDlg, &rcClient); hBrush = (HBRUSH)SendMessage(hDlg, GET_WM_CTLCOLOR_MSG(CTLCOLOR_DLG), GET_WM_CTLCOLOR_MPS( (HDC)wParam,hDlg,CTLCOLOR_DLG)); FillRect((HDC)wParam,&rcClient,hBrush); APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 1\n")); return (LRESULT)1; case WM_SHOWWINDOW: /* if we are hiding, save the focus */ if (!wParam) SaveDlgFocus(hDlg); rc = DefWindowProc(hDlg,iMessage,wParam,lParam); APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc)); return rc; case WM_SYSCOMMAND: if ((wParam & 0xfff0) == SC_MINIMIZE) SaveDlgFocus(hDlg); rc = DefWindowProc(hDlg,iMessage,wParam,lParam); APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc)); return rc; case WM_ACTIVATE: if GET_WM_ACTIVATE_STATE(wParam,lParam) RestoreDlgFocus(hDlg); else SaveDlgFocus(hDlg); break; case WM_SETFOCUS: if (!RestoreDlgFocus(hDlg)) DlgSetFocus(GetFirstDlgTabItem(hDlg)); break; case WM_CLOSE: hWndChild = GetDlgItem(hDlg, IDCANCEL); if (hWndChild) { dwStyle = GetWindowLong(hDlg,GWL_STYLE); if (dwStyle & WS_DISABLED) { MessageBeep(0); } else PostMessage(hDlg,WM_COMMAND, GET_WM_COMMAND_MPS(IDCANCEL, hWndChild,BN_CLICKED)); } break; case WM_NCDESTROY: SetWindowWord(hDlg,DWW_STATUS,1); if ((hFont = (HFONT)GetWindowWord(hDlg, DWW_HFONT))) { DeleteObject(hFont); SetWindowWord(hDlg,DWW_HFONT,0); } DefWindowProc(hDlg,iMessage,wParam,lParam); break; case DM_SETDEFID: SetWindowWord(hDlg,DWW_DEFID,wParam); APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 1\n")); return (LRESULT)1; case DM_GETDEFID: wTmp = GetWindowWord(hDlg,DWW_DEFID); if (wTmp) { rc = MAKELRESULT(wTmp, DC_HASDEFID); APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc)); return rc; } else { APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 0\n")); return (LRESULT)0; } case WM_NEXTDLGCTL: hWndFocus = GetFocus(); if (LOWORD(lParam)) { if (!hWndFocus) hWndFocus = hDlg; hWndChild = (HWND)wParam; } else { if (!hWndFocus) { /* set to the first tab item */ hWndChild = GetFirstDlgTabItem(hDlg); hWndFocus = hDlg; } else { if (!IsChild(hDlg,hWndFocus)) return (LRESULT)1; hWndChild = GetNextDlgTabItem(hDlg, hWndFocus,(BOOL)wParam); } } DlgSetFocus(hWndChild); CheckDefPushButton(hDlg,hWndFocus,hWndChild); APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 1\n")); return (LRESULT)1; case WM_GETFONT: rc = (LRESULT)GetWindowWord(hDlg,DWW_HFONT); APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc)); return rc; case WM_SETFONT: SetWindowWord(hDlg,DWW_HFONT,(HFONT)wParam); if (LOWORD(lParam)) InvalidateRect(hDlg,NULL,TRUE); APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",0)); return 0L; case WM_VKEYTOITEM: case WM_COMPAREITEM: case WM_CHARTOITEM: case WM_INITDIALOG: break; case WM_MOUSEACTIVATE: rc = (LRESULT)MA_ACTIVATE; if ((int)(short)LOWORD(lParam) == HTCAPTION) rc = (LRESULT)MA_NOACTIVATE; APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc)); return rc; #ifdef TWIN32 case WM_CTLCOLORMSGBOX: case WM_CTLCOLORBTN: case WM_CTLCOLORDLG: case WM_CTLCOLORSTATIC: rc = GetStockObject(LTGRAY_BRUSH); APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc)); return rc; #endif default: rc = DefWindowProc(hDlg,iMessage,wParam,lParam); APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc)); return rc; } }
//*********************************************************************** void CJungleScene::HandlePuzzle1Buttons( HWND hWnd, ITEMID id ) //*********************************************************************** { int iSndID = GetWindowWord( GetDlgItem(hWnd, id), GWW_ICONID ); if ( !iSndID ) iSndID = id; // Get the current shot info from the video LPVIDEO lpVideo = (LPVIDEO)GetWindowLong( GetDlgItem(hWnd, IDC_VIDEO_GAME), GWL_DATAPTR ); if ( !lpVideo) return; LPSHOT lpShot = &lpVideo->lpAllShots [lpVideo->lCurrentShot - 1]; if (!lpShot) return; // Extract the shot number int iShotNum = (int)(lpShot->lFlags & A_VALUE_BITS); // How many items in the list? int nItems = sizeof(m_PuzzleInfo) / sizeof(VRECOINFO); // Get the index of the item matching the shot for ( int idx = 0; idx < nItems; idx++ ) { if ( iShotNum == m_PuzzleInfo[idx].iShotNum ) break; } if ( idx == nItems ) return; // Couldn't find the shot in the list int iNxtSyllable = m_PuzzleInfo[idx].iSyllables[nMatches]; int iNumSyllables = m_PuzzleInfo[idx].sNumSyllables; // Does the button match the next syllable? if (iSndID == iNxtSyllable) { // int iState = GetWindowWord( GetDlgItem(hWnd, id), GWW_STATE ); // SendMessage( GetDlgItem(hWnd, id), SM_SETSTATE, !iState, 0L); SendMessage( GetDlgItem(hWnd, id), SM_SETSTATE, 1, 0L); // Give them instinct points ChangeInstinctMeter (hWnd, GOOD_RESPONSE); // Set progress meter nMatches++; long lProgress = (METER_MAX * nMatches) / (long)iNumSyllables; SendMessage( GetDlgItem(hWnd, IDC_PUZ_PROGRESS), SM_SETPOSITION, 0, lProgress ); // Is this the last syllable? if (nMatches >= iNumSyllables) { // Delay so the progress meter is shown Delay( 1500 ); // Simulate an EVENT_DOWN (good response) to the video control FORWARD_WM_KEYDOWN (GetDlgItem(hWnd, IDC_VIDEO_GAME), VK_DOWN, 0/*cRepeat*/, 0/*flags*/, SendMessage); } return; } // It is not a match // Take instinct points away ChangeInstinctMeter (hWnd, BAD_RESPONSE); // // Simulate a wrong button pressed // FORWARD_WM_KEYDOWN (GetDlgItem(hWnd, IDC_VIDEO_GAME), VK_UP, // 0/*cRepeat*/, 0/*flags*/, SendMessage); }
/**************************************************************************** * * * FUNCTION : DdeCallback() * * * * PURPOSE : This handles all callbacks from the DDEML. This handles * * updating of the associated conversation and any special * * testing cases such as blocking callbacks etc. * * * * For the most part, clients only handle advise data and * * asynchronous transaction completion here. * * * * RETURNS : Results vary depending on transaction type. * * * ****************************************************************************/ HDDEDATA EXPENTRY DdeCallback( WORD wType, WORD wFmt, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hData, DWORD lData1, DWORD lData2) { HWND hwnd; CONVINFO ci; XACT *pxact; if (hConv) { /* * update conversation status if it changed. */ MYCONVINFO *pmci; ci.cb = sizeof(CONVINFO); if (!DdeQueryConvInfo(hConv,(DWORD) QID_SYNC, &ci) || (!IsWindow((HWND)ci.hUser))) { /* * This conversation does not yet have a corresponding MDI window * or is disconnected. */ return 0; } if (pmci = (MYCONVINFO *)GetWindowWord((HWND)ci.hUser, 0)) { if (pmci->ci.wStatus != ci.wStatus || pmci->ci.wConvst != ci.wConvst || pmci->ci.wLastError != ci.wLastError) { /* * Things have changed, updated the conversation window. */ InvalidateRect((HWND)ci.hUser, NULL, TRUE); } if (ci.wConvst & ST_INLIST) { /* * update the associated list window (if any) as well. */ if (hwnd = FindListWindow(ci.hConvList)) InvalidateRect(hwnd, NULL, TRUE); } } } /* * handle special block on next callback option here. This demonstrates * the CBR_BLOCK feature. */ if (fBlockNextCB && !(wType & XTYPF_NOBLOCK)) { fBlockNextCB = FALSE; return(CBR_BLOCK); } /* * handle special termination here. This demonstrates that at any time * a client can drop a conversation. */ if (fTermNextCB && hConv && wType != XTYP_DISCONNECT) { fTermNextCB = FALSE; MyDisconnect(hConv); return(0); } /* * Now we begin sort out what to do. */ switch (wType) { case XTYP_REGISTER: case XTYP_UNREGISTER: /* * This is where the client would insert code to keep track of * what servers are available. This could cause the initiation * of some conversations. */ break; case XTYP_DISCONNECT: if (fAutoReconnect) { /* * attempt a reconnection */ if (hConv = DdeReconnect(hConv)) { AddConv(ci.hszServiceReq, ci.hszTopic, hConv, FALSE); return 0; } } /* * update conv window to show its new state. */ SendMessage((HWND)ci.hUser, UM_DISCONNECTED, 0, 0); return 0; break; case XTYP_ADVDATA: /* * data from an active advise loop (from a server) */ Delay(wDelay); hwnd = FindAdviseChild((HWND)ci.hUser, hsz2, wFmt); if (!IsWindow(hwnd)) { PSTR pszItem, pszFmt; /* * AdviseStart window is gone, make a new one. */ pxact = (XACT *)MyAlloc(sizeof(XACT)); pxact->wType = wType; pxact->hConv = hConv; pxact->wFmt = wFmt; pxact->hszItem = hsz2; DdeKeepStringHandle(idInst, hsz2); pszItem = GetHSZName(hsz2); pszFmt = GetFormatName(wFmt); hwnd = CreateInfoCtrl(NULL, (int)SendMessage((HWND)ci.hUser, UM_GETNEXTCHILDX, 0, 0L), (int)SendMessage((HWND)ci.hUser, UM_GETNEXTCHILDY, 0, 0L), 200, 100, (HWND)ci.hUser, hInst, Type2String(wType, 0), (LPSTR)pszItem, NULL, NULL, (LPSTR)pszFmt, NULL, ICSTY_SHOWFOCUS, 0, (DWORD)(LPSTR)pxact); MyFree(pszFmt); MyFree(pszItem); if (!IsWindow(hwnd)) return(DDE_FNOTPROCESSED); } if (!hData) { /* * XTYPF_NODATA case - request the info. (we do this synchronously * for simplicity) */ hData = DdeClientTransaction(NULL, 0L, hConv, hsz2, wFmt, XTYP_REQUEST, DefTimeout, NULL); } if (hData) { PSTR pData; /* * Show incomming data on corresponding transaction window. */ pData = GetTextData(hData); SendMessage(hwnd, ICM_SETSTRING, ICSID_CENTER, (DWORD)(LPSTR)pData); MyFree(pData); DdeFreeDataHandle(hData); } SendMessage(hwnd, ICM_SETSTRING, ICSID_LL, (DWORD)(LPSTR)"Advised"); return(DDE_FACK); break; case XTYP_XACT_COMPLETE: /* * An asynchronous transaction has completed. Show the results. * * ...unless the XOPT_BLOCKRESULT is chosen. */ ci.cb = sizeof(CONVINFO); if (DdeQueryConvInfo(hConv, lData1, &ci) && IsWindow((HWND)ci.hUser) && (pxact = (XACT *)GetWindowWord((HWND)ci.hUser, GWW_WUSER))) { if (pxact->fsOptions & XOPT_BLOCKRESULT) { pxact->fsOptions &= ~XOPT_BLOCKRESULT; return(CBR_BLOCK); } pxact->Result = lData2; pxact->ret = hData; CompleteTransaction((HWND)ci.hUser, pxact); } break; } }
/* * StartUpDriver - the main message handling loop */ long __export FAR PASCAL StartUpDriver( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) { FARPROC farproc; HWND tmpw; int len; char data[_MAX_PATH]; char tmp[80 + _MAX_PATH]; HINSTANCE inst; switch( message ) { case WM_DESTROY: PostQuitMessage( 0 ); break; case WM_COMMAND: switch( wparam ) { case MSG_ABOUT: inst = (HINSTANCE)GetWindowWord( hwnd, GWW_HINSTANCE ); farproc = MakeProcInstance( (FARPROC)About2, inst ); DialogBox( inst, ResName( "AboutBox" ), hwnd, (DLGPROC)farproc ); FreeProcInstance( farproc ); SetFocus( editChild ); break; case PUSH_GETFILES_ID: case MSG_GETFILES: data[0] = 0; if( getFile( data ) ) { GetWindowText( editChild, tmp, sizeof( tmp ) ); strcat( tmp, data ); SetWindowText( editChild, tmp ); } SetFocus( editChild ); break; case PUSH_OK_ID: case SELECT_ID: len = GetWindowTextLength( editChild ) + 1; if( len > _MAX_PATH ) len = _MAX_PATH; GetWindowText( editChild, dataPtr, len ); canContinue = TRUE; tmpw = GetParent( editChild ); SetWindowLong( editChild, GWL_WNDPROC, (LONG) oldClassProc ); /* fall through, like exit was picked */ case MSG_EXIT: DestroyWindow( mainWindow ); PostQuitMessage( 0 ); break; } /* switch */ break; default: return( DefWindowProc(hwnd,message,wparam,lparam) ); } /* switch */ return( 0L ); } /* StartUpDriver */
/**************************************************************************** * * * Function: HypCtrlWndProc * * * * Purpose : Process Hyperlink control messages. * * * * History : Date Reason * * 00/00/00 Created * * * ****************************************************************************/ static LRESULT CALLBACK HypCtrlWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg){ case WM_LBUTTONUP: { HYPCTRL* pHcWnd = (HYPCTRL*) GetWindowLong(hWnd, WND_HYPSTRUCT); if (pHcWnd->bPlaySound) PlayNavigatingSound(); if (pHcWnd->cbFn != NULL) { // call user function (callback) pHcWnd->cbFn(pHcWnd->cbID); } else { // jump to link ShellExecute(NULL, _T("open"), pHcWnd->szLink, NULL, NULL, SW_SHOW); } return FALSE; } case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; RECT rect; HYPCTRL* pHcWnd = (HYPCTRL*) GetWindowLong(hWnd, WND_HYPSTRUCT); BOOL bIsOverControl = (BOOL) GetWindowWord(hWnd, WND_ISHOVER); rect.left = (LONG) GetWindowLong(hWnd, WND_LEFT); rect.top = (LONG) GetWindowLong(hWnd, WND_TOP); rect.right = (LONG) GetWindowLong(hWnd, WND_RIGHT); rect.bottom = (LONG) GetWindowLong(hWnd, WND_BOTTOM); hdc = BeginPaint(hWnd, &ps); if (bIsOverControl) { // draws hover state SetBkColor(hdc, (COLORREF) pHcWnd->bgcHover); SelectObject(hdc, (HFONT) GetWindowLong(hWnd, WND_FONTH)); SetTextColor(hdc, pHcWnd->fgcHover); } else { // draws normal state SetBkColor(hdc, (COLORREF) pHcWnd->bgcNormal); SelectObject(hdc, (HFONT) GetWindowLong(hWnd, WND_FONTN)); SetTextColor(hdc, pHcWnd->fgcNormal); } // draw the text DrawText(hdc, pHcWnd->szText, -1, &rect, pHcWnd->dtStyle); EndPaint(hWnd, &ps); return FALSE; } case WM_CAPTURECHANGED: SetWindowWord(hWnd, WND_ISHOVER, (WORD) FALSE); InvalidateRect(hWnd, NULL, TRUE); return FALSE; case WM_MOUSEMOVE: { RECT rect; rect.left = (LONG) GetWindowLong(hWnd, WND_LEFT); rect.top = (LONG) GetWindowLong(hWnd, WND_TOP); rect.right = (LONG) GetWindowLong(hWnd, WND_RIGHT); rect.bottom = (LONG) GetWindowLong(hWnd, WND_BOTTOM); // check if mouse is over control if ((BOOL) GetWindowWord(hWnd, WND_ISHOVER)) { POINT ptMousePos; DWORD dwMousePos; dwMousePos = GetMessagePos(); ptMousePos.x = LOWORD(dwMousePos); ptMousePos.y = HIWORD(dwMousePos); ScreenToClient(hWnd, &ptMousePos); if (!(BOOL) PtInRect(&rect, ptMousePos)) { SetWindowWord(hWnd, WND_ISHOVER, (WORD) FALSE); InvalidateRect(hWnd, &rect, TRUE); ReleaseCapture(); } } else { SetWindowWord(hWnd, WND_ISHOVER, (WORD) TRUE); InvalidateRect(hWnd, &rect, TRUE); SetCapture(hWnd); } return FALSE; } case WM_CLOSE: { HYPCTRL* pHcWnd = (HYPCTRL*) GetWindowLong(hWnd, WND_HYPSTRUCT); HFONT hFontTemp; // clean up if (pHcWnd->szLink) GlobalFreePtr(pHcWnd->szLink); if (pHcWnd->szText) GlobalFreePtr(pHcWnd->szText); if (pHcWnd->szTooltip) GlobalFreePtr(pHcWnd->szTooltip); if (pHcWnd->cbFn) GlobalFreePtr(pHcWnd->cbFn); hFontTemp = (HFONT) GetWindowLong(hWnd, WND_FONTN); if (hFontTemp) DeleteObject(hFontTemp); hFontTemp = (HFONT) GetWindowLong(hWnd, WND_FONTH); if (hFontTemp) DeleteObject(hFontTemp); if (pHcWnd) GlobalFreePtr(pHcWnd); DestroyWindow(hWnd); return FALSE; } } return DefWindowProc(hWnd, msg, wParam, lParam); }
LOCAL void Slider_Paint (HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight) /***********************************************************************/ { BOOL bHasFocus, bSelected, bDown; DWORD dwStyle; RECT rSrcArea, rDstArea; POINT ptDst; UINT id; PDIB pdibSrc, pdibDst; HDC hWinGDC; LPHSLIDERINFO lpInfo; if (! (lpInfo = (LPHSLIDERINFO)GetWindowLong (hWindow, GWL_DATAPTR) ) ) return; rSrcArea = *lpRect; rDstArea = *lpRect; MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rDstArea, 2 ); LPSCENE lpScene = CScene::GetScene (GetParent (hWindow) ); if (! lpScene) return; if ( !lpScene->GetDIBs( &pdibSrc, &pdibDst, &hWinGDC ) ) return; if ( !pdibSrc || !pdibDst || !hWinGDC ) return; bSelected = GetWindowWord (hWindow, GWW_STATE); dwStyle = GetWindowStyle(hWindow); bHasFocus = (GetFocus () == hWindow); bDown = ( bSelected || (lpInfo->bTrack && lpInfo->bInRect && bHasFocus) ); // Repair the dirty bitmap with the clean bitmap if ( pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8) { // compressed DIBs must use GDI copying (lose transparency ability) pdibSrc->DCBlt( hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top ); } else { pdibSrc->DibBlt( pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, NO /*bTransparent*/ ); } // Draw the slider background RECT rSlider = lpInfo->rSlider; RECT rInner = lpInfo->rSlider; rInner.top = lpInfo->iCenter - (lpInfo->iTrackWidth / 2); rInner.bottom = lpInfo->iCenter + (lpInfo->iTrackWidth / 2); MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rSlider, 2); MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rInner, 2); // Turn off tick painting because using background bitmap #ifdef UNUSED HBRUSH hBrush = CreateSolidBrush (lpInfo->rgbBackgnd); HBRUSH hBrush2 = (HBRUSH)GetStockObject (BLACK_BRUSH); FillRect (hWinGDC, & rSlider, hBrush); FillRect (hWinGDC, & rInner, hBrush2); DeleteObject (hBrush); #endif RECT rClient; GetClientRect (hWindow, & rClient); MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rClient, 2 ); // Turn off tick painting because using background bitmap #ifdef UNUSED // Draw a chiselled border RECT rBorder = rClient; InflateRect (& rBorder, 1, 1); int cxButton = rBorder.right - rBorder.left; int cyButton = rBorder.bottom - rBorder.top; HPEN hLitePen = CreatePen (PS_SOLID, 1, RGB (255, 255, 255)); HPEN hDarkPen = CreatePen (PS_SOLID, 1, RGB (128, 128, 128)); HPEN hOldPen = (HPEN)SelectObject (hWinGDC, hLitePen); MoveToEx (hWinGDC, rBorder.left, rBorder.bottom - 1, NULL); LineTo (hWinGDC, rBorder.left, rBorder.top); LineTo (hWinGDC, rBorder.right - 1, rBorder.top); MoveToEx (hWinGDC, rBorder.left + 1, rBorder.bottom - 2, NULL); LineTo (hWinGDC, rBorder.left + 1, rBorder.top + 1); LineTo (hWinGDC, rBorder.right - 2, rBorder.top + 1); SelectObject (hWinGDC, hDarkPen); MoveToEx (hWinGDC, rBorder.right - 1, rBorder.top, NULL); LineTo (hWinGDC, rBorder.right - 1, rBorder.bottom - 1); LineTo (hWinGDC, rBorder.left, rBorder.bottom - 1); MoveToEx (hWinGDC, rBorder.right - 2, rBorder.top + 1, NULL); LineTo (hWinGDC, rBorder.right - 2, rBorder.bottom - 2); LineTo (hWinGDC, rBorder.left + 1, rBorder.bottom - 2); SelectObject (hWinGDC, hOldPen); DeleteObject (hLitePen); DeleteObject (hDarkPen); // If tick-marks are wanted if (lpInfo->iTicks) { int pw = 2; // pen width HPEN hTickPen = CreatePen (PS_SOLID, pw, lpInfo->rgbBackgnd); hOldPen = (HPEN)SelectObject (hWinGDC, hTickPen); int iBmpWidth = lpInfo->rBitmap.right - lpInfo->rBitmap.left; int wx = rClient.right - rClient.left - iBmpWidth; int dx = wx / lpInfo->iTicks; wx = wx - (dx * lpInfo->iTicks) - pw; int x = rClient.left + (iBmpWidth + wx + pw) / 2; // wx is now the excess int y1 = rClient.top + 2; int y2 = y1 + 10; for (int idx = 0; idx <= lpInfo->iTicks ; idx++) { MoveToEx (hWinGDC, x, y1, NULL); LineTo (hWinGDC, x, y2); x += dx; } SelectObject (hWinGDC, hOldPen); DeleteObject (hTickPen); } #endif rSrcArea = lpInfo->rBitmap; rDstArea = lpInfo->rBitmap; MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rDstArea, 2 ); // Get the control ID to load the bitmap resource if (! (id = GetWindowWord (hWindow, GWW_ICONID) ) ) id = GET_WINDOW_ID (hWindow); if (pdibSrc = CDib::LoadDibFromResource (GetWindowInstance (hWindow), MAKEINTRESOURCE(id), GetApp()->m_hPal, (dwStyle & BS_MASK) != 0 )) { // Load the resource if ( pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8 ) { // compressed DIBs must use GDI copying (lose transparency ability) pdibSrc->DCBlt( hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top ); } else { RGBTRIPLE rgb; LPRGBTRIPLE lpRGB = NULL; if (dwStyle & BS_MASK) { STRING szColor; GetWindowText(hWindow, szColor, sizeof(szColor)); AsciiRGB( szColor, &rgb ); lpRGB = &rgb; } if (dwStyle & BS_HIGHLIGHT) { // Get the transparency color BYTE bTrans = *pdibSrc->GetXY(0, 0); // Get the color to replace LPTR lpColor = pdibSrc->GetXY(1, 0); BYTE bColor = *lpColor; *lpColor = bTrans; // Get the hightlight color LPTR lpHighlight = pdibSrc->GetXY(2, 0); BYTE bHighlight = *lpHighlight; *lpHighlight = bTrans; // Replace the pixels in the DIB if (bDown && (bColor != bHighlight)) { HPTR hp = pdibSrc->GetPtr(); DWORD dwSize = pdibSrc->GetSizeImage(); while ( dwSize-- ) { if (*hp == bColor) *hp = bHighlight; ++hp; } } } // Set slider position if needed if (lpInfo->Position) { int iBmpWidth = lpInfo->rBitmap.right - lpInfo->rBitmap.left; int iWidth = rClient.right - rClient.left - iBmpWidth; int x = (int)(((long)(lpInfo->Position - lpInfo->Min) * iWidth) / (lpInfo->Max - lpInfo->Min)); rDstArea.left += x; if (rDstArea.left < rClient.left) rDstArea.left = rClient.left; else if (rDstArea.left + iBmpWidth > rClient.right) rDstArea.left = rClient.right - iBmpWidth; rDstArea.right = rDstArea.left + iBmpWidth; } pdibSrc->DibBlt( pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top, (dwStyle & BS_TRANSPARENT) != 0 /*bTransparent*/, lpRGB ); } delete pdibSrc; } ptDst.x = rSrcArea.left; ptDst.y = rSrcArea.top; if (lpScene) lpScene->Paint( hDC, &rClient, &ptDst ); }