| | |
Win32 - WM_PAINT and 'Button Windows'
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
I cant figure out how make the Button visible proccessing WM_PAINT myself, it just get visible after pressing it..
I dont get whats going on, since WS_VISIBLE is set...( I dont know what WS_VISIBLE is at all, I tried create my main window with WS_VISIBLE, but I STILL need to call ShowWindow, or notting is displaied )..
Not handling WM_PAINT myself solve the problem.
Using BeginPaint / EndPaint at the WM_PAINT solve the problem too.
So, what I have to do ?( I want proccess WM_PAINT myself, using GetDC / Release DC instead of Begin / EndPaint )
C++ Syntax (Toggle Plain Text)
//THE WM_PAINT message: case WM_PAINT:{ RECT myrect; //get the device contest for the current window------------------- gsp_hdc = GetDC( hWnd ); if( !gsp_hdc ){ MessageBox( NULL, TEXT(" Error Getting DC!"), TEXT(" error"), MB_ICONEXCLAMATION | MB_OK ); gsp_error_id = GetLastError(); return 0; } //-------------------------------------------------------------- //paint--------------------------------------------------------- gsp_old_txtcolor = SetTextColor( gsp_hdc, RGB( 255, 0, 0 ) ); //gsp_old_bgcolor = SetBkColor( gsp_hdc, RGB( 0, 0, 0 ) ); SetBkMode( gsp_hdc, TRANSPARENT ); /* all the functions above returns the not more current value, so you can save it for backup */ TextOut( gsp_hdc, 0, 0, TEXT(" My text "), 9 ); DrawText( gsp_hdc, TEXT(" My other balacodation text,\r\nwith lots and lots of words...\r\njust to see what happens... "), (int)strlen (" My other balacodation text,\r\nwith lots and lots of words...\r\njust to see what happens... "), &gsp_textrect, DT_LEFT ); /* strlen counts the numbers of characters on a string */ //--------------------------------------------------------------- ReleaseDC( hWnd, gsp_hdc ); //cada GetDC precisa de um ReleaseDC GetClientRect( hWnd, &myrect ); ValidateRect( hWnd, &myrect );//WM_PAINT donne! ( NULL apaga tudo ) }break;
C++ Syntax (Toggle Plain Text)
//THE BUTTON CREATION: HWND gsp_button1; gsp_button1 = CreateWindow( TEXT("Button"), TEXT("My Button"), WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON, 300, 300, 150, 50, gsp_hmainwnd,(HMENU) 100, hInstance, NULL );
C++ Syntax (Toggle Plain Text)
//THE MAIN WINDOW(parent): HWND gsp_hmainwnd; //the window handle gsp_hmainwnd = CreateWindowEx( WS_EX_APPWINDOW | WS_EX_OVERLAPPEDWINDOW/* | WS_EX_TOPMOST*/, //EX style TEXT("GSP Main Windows Class"), TEXT("GSP Main Window"), //Name Classe, Name Window WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_CAPTION | WS_SIZEBOX, //style CW_USEDEFAULT, NULL, //x, y CW_USEDEFAULT, CW_USEDEFAULT, //w, h NULL, NULL, //pai, menu hInstance, NULL ); //instance module, value?
C++ Syntax (Toggle Plain Text)
//THE WINDOW CLASS STRUCTURE RESGISTERED: WNDCLASSEX gsp_wc;//the window class structure gsp_wc.cbSize = sizeof( WNDCLASSEX ); //tamanho da estrutura(em bytes) gsp_wc.style = CS_HREDRAW | CS_VREDRAW; //estilo da classe( varias opçoes CS_..) gsp_wc.lpfnWndProc = gsp_MainWndProc; //pointer pro 'wndproc' gsp_wc.cbClsExtra = 0; //class extra bytes gsp_wc.cbWndExtra = 0; //window extra bytes gsp_wc.hInstance = hInstance; //instance q tem o 'wndproc' gsp_wc.hIcon = (HICON)LoadImage( NULL, TEXT("gsp_TsmIcon.ico"), IMAGE_ICON, 16, 16, LR_LOADFROMFILE|LR_SHARED);//LoadIcon( NULL, IDI_APPLICATION ); //large icon( ALT+TAB )TEM q ser NULL a hInstance.. gsp_wc.hCursor = LoadCursor( NULL, IDC_ARROW ); //cursor gsp_wc.hIconSm = (HICON)LoadImage( NULL, TEXT("gsp_TsmIcon.ico"), IMAGE_ICON, 16, 16, LR_LOADFROMFILE|LR_SHARED);//small icon(caption, barr..) gsp_wc.hbrBackground = (HBRUSH) COLOR_BACKGROUND + 1; //cor de fundo//pode ser: (HBRUSH) GetStockObject( BLACK_BRUSH ); gsp_wc.lpszMenuName = TEXT("RC_GSP_MAINMENU"); //nome do menu gsp_wc.lpszClassName = TEXT("GSP Main Windows Class"); //nome da classe( identificador) //--------------------------------------------------------------
I dont get whats going on, since WS_VISIBLE is set...( I dont know what WS_VISIBLE is at all, I tried create my main window with WS_VISIBLE, but I STILL need to call ShowWindow, or notting is displaied )..
Not handling WM_PAINT myself solve the problem.
Using BeginPaint / EndPaint at the WM_PAINT solve the problem too.
So, what I have to do ?( I want proccess WM_PAINT myself, using GetDC / Release DC instead of Begin / EndPaint )
![]() |
Similar Threads
- Windows Vista Infected Big Time!! (Viruses, Spyware and other Nasties)
- Infected with Hoax.Win32.Renos.vaoz. Please Help!! (Viruses, Spyware and other Nasties)
- Windows Live Messenger Pic.zip trojan infected.. (Viruses, Spyware and other Nasties)
- Virtomonde and win32.trojan.agent help (Viruses, Spyware and other Nasties)
- Backdoor.Win32.Loony.m (Viruses, Spyware and other Nasties)
- Help!! I Have The "new Poly Win32 Virus" Plz Help (Viruses, Spyware and other Nasties)
- Windows message box "Restore" when windows 98 loads (Viruses, Spyware and other Nasties)
Other Threads in the C++ Forum
- Previous Thread: Execute an Aplication Using C++
- Next Thread: Need the actual logic of beelow problem
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph homeworkhelp iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





