Subj : Re: Need a little help To : borland.public.cpp.borlandcpp From : Jeff Baker Date : Sat May 29 2004 03:33 pm Thanks Ed, your suggestion worked. I keep overlooking the basics. I placed the InvalidateRect() and UpdateWindow() in the ProcessMenuSelection() function and everything works fine (with a few other changes). When I placed them in the DisplayCentigrade() and DisplayFahrenheit() functions the screen kept refreshing itself (looked pretty cool actually). Here is how it looks now; [START OF CODE] void DisplayCentigrade(HWND hwnd,HDC hdc,HDC hdcMem) { HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem,ga_centigrage); GetObject(ga_centigrage,sizeof(bitmap),&bitmap); BitBlt(hdc,787,679,bitmap.bmWidth,bitmap.bmHeight,hdcMem,0,0,SRCCOPY); SelectObject(hdcMem,hbmOld); } void DisplayFahrenheit(HWND hwnd,HDC hdc,HDC hdcMem) { HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem,ga_fahrenheit); GetObject(ga_fahrenheit,sizeof(bitmap),&bitmap); BitBlt(hdc,787,679,bitmap.bmWidth,bitmap.bmHeight,hdcMem,0,0,SRCCOPY); SelectObject(hdcMem,hbmOld); } void ProcessMenuSelection(HWND hwnd,WPARAM wParam) { HMENU menu; int accept_change; switch(LOWORD(wParam)) { case ID_TEMP_C: accept_change = MessageBox(hwnd,"Oil temperature will be displayed using the Centigrade scale","Configuration Change Notice",MB_OKCANCEL | MB_ICONINFORMATION); if (accept_change == IDOK) { temp_select = CENTIGRADE; menu = GetMenu(hwnd); CheckMenuItem(menu,ID_TEMP_C,MF_CHECKED); CheckMenuItem(menu,ID_TEMP_F,MF_UNCHECKED); HDC hdc = BeginPaint(hwnd,&paint_struct); HDC hdcMem = CreateCompatibleDC(hdc); if (hdcMem == NULL) { LPVOID message_buffer; MessageBeep(MB_ICONEXCLAMATION); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORM AT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLAN G_DEFAULT),(LPTSTR) &message_buffer,0,NULL); MessageBox(NULL,(LPCTSTR)message_buffer,app_name,MB_ICONEXCLAMATION|MB_OK|MB _SYSTEMMODAL); LocalFree(message_buffer); } DisplayCentigrade(hwnd,hdc,hdcMem); InvalidateRect(hwnd,NULL,TRUE); UpdateWindow(hwnd); DeleteDC(hdcMem); EndPaint(hwnd,&paint_struct); } break; case ID_TEMP_F: accept_change = MessageBox(hwnd,"Oil temperature will be displayed using the Fahrenheit scale","Configuration Change Notice",MB_OKCANCEL | MB_ICONINFORMATION); if (accept_change == IDOK) { temp_select = FAHRENHEIT; menu = GetMenu(hwnd); CheckMenuItem(menu,ID_TEMP_F,MF_CHECKED); CheckMenuItem(menu,ID_TEMP_C,MF_UNCHECKED); HDC hdc = BeginPaint(hwnd,&paint_struct); HDC hdcMem = CreateCompatibleDC(hdc); if (hdcMem == NULL) { LPVOID message_buffer; MessageBeep(MB_ICONEXCLAMATION); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORM AT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLAN G_DEFAULT),(LPTSTR) &message_buffer,0,NULL); MessageBox(NULL,(LPCTSTR)message_buffer,app_name,MB_ICONEXCLAMATION|MB_OK|MB _SYSTEMMODAL); LocalFree(message_buffer); } DisplayFahrenheit(hwnd,hdc,hdcMem); InvalidateRect(hwnd,NULL,TRUE); UpdateWindow(hwnd); DeleteDC(hdcMem); EndPaint(hwnd,&paint_struct); } break; break; } } LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { switch(msg) { case WM_CREATE: { ga_bmp = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_GA)); ga_centigrage = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_CENTIGRADE)); ga_fahrenheit = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_FAHRENHEIT)); break; } case WM_PAINT: { HDC hdc = BeginPaint(hwnd,&paint_struct); HDC hdcMem = CreateCompatibleDC(hdc); if (hdcMem == NULL) { LPVOID message_buffer; MessageBeep(MB_ICONEXCLAMATION); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORM AT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLAN G_DEFAULT),(LPTSTR) &message_buffer,0,NULL); MessageBox(NULL,(LPCTSTR)message_buffer,app_name,MB_ICONEXCLAMATION|MB_OK|MB _SYSTEMMODAL); LocalFree(message_buffer); } HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem,ga_bmp); GetObject(ga_bmp,sizeof(bitmap),&bitmap); BitBlt(hdc,0,0,bitmap.bmWidth,bitmap.bmHeight,hdcMem,0,0,SRCCOPY); SelectObject(hdcMem,hbmOld); if (CGA.temp_select == CENTIGRADE) DisplayCentigrade(hwnd,hdc,hdcMem); else DisplayFahrenheit(hwnd,hdc,hdcMem); DeleteDC(hdcMem); EndPaint(hwnd,&paint_struct); } break; [END OF CODE] Thanks again Ed for putting up with my rookie questions, your the BEST! - Jeff Baker "Ed Mulroy [TeamB]" wrote in message news:40b78eeb@newsgroups.borland.com... > Once the user has changed the setting and your functions have altered > the memory bitmap how is Windows to know that you wish that it repaint > the window? > > Try adding these lines at the end of the DisplayCentigrade and > DisplayFahrenheit functions. > > InvalidateRect(hwnd, NULL, TRUE); > UpdateWindow(hwnd); > > . Ed > > > Jeff Baker wrote in message > > news:40b78cb1@newsgroups.borland.com... > > .