I cant figure out how make the Button visible proccessing WM_PAINT myself, it just get visible after pressing it..

//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;
//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 );
//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?
//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 )

Can't imagine why you are using GetDC(), ReleaseDC() in WM_PAINT. That isn't done. There is no reason whatsoever to do that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.