Archived

This topic is now archived and is closed to further replies.

Button showing

This topic is 5623 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hwndbutton=CreateWindowEx(NULL,"button","asdas",WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON,100,100,200,24,hwnd,(HMENU)(1112),hInstance,NULL); I am using this code but it isn´t chowing my button until i "guess" the local of it and click in it ... I can´t figure out what is wrong... Thanx in advance

Share this post


Link to post
Share on other sites
You definately shouldn''t be putting UpdateWindow in the message loop as that is sending loads of WM_PAINT messages and possible WM_NCPAINT messages too. It seems that something is drawing over the button. Make sure that in your code there is nothing that would draw a rectangle over the area that the button is contained in. Check the WM_PAINT message if you have one, or WM_SIZE message to see if something is drawing where it shouldn''t be.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
well i am using ShowWindow for parent hwnd, and the button uses the parent hwnd, and in my WM_PAINT i have InvalidateRect

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
here is the whole code:

  
#include<windows.h>
#include<windowsx.h>
#include"resource.h"
#include<stdlib.h>
#include<stdio.h>
#define WN32_LEAN_AND_MEAN
const char sz_classewin[7]="classe";
HINSTANCE hInstance_app;

LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{


RECT rect;
switch(msg)
{
case WM_COMMAND:


if(wParam==1112)
{

InvalidateRect(hwnd,&rect,0);
}

case WM_CREATE:
{

return(0);
}break;
case WM_DESTROY:
{

PostQuitMessage(0);
}break;
case WM_PAINT:
{

GetWindowRect(hwnd,&rect);

ValidateRect(hwnd,&rect);
}break;


default:
break;
}

return(DefWindowProc(hwnd,msg,wParam,lParam));
}



int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASSEX janela;
HWND hwnd;
MSG msg;
HDC hdc;
HPEN blue_pen= CreatePen(PS_SOLID,1,RGB(0,0,255));
HBRUSH red_brush= CreateSolidBrush(RGB(255,0,0));
RECT rect= {100,10,200,20};
POINT poly[5]={100,70,100,400};


janela.cbSize=sizeof(WNDCLASSEX);
janela.style=CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW|CS_OWNDC;
janela.lpfnWndProc=WndProc;
janela.cbClsExtra=0;
janela.cbWndExtra=0;
janela.hInstance=hInstance;
janela.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));
janela.hCursor=LoadCursor(NULL,IDC_ARROW);
janela.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
janela.lpszMenuName="MENU1";
janela.lpszClassName=sz_classewin;
janela.hIconSm=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));
hInstance_app=hInstance;

RegisterClassEx(&janela);

hwnd=CreateWindowEx(NULL,sz_classewin,"Janela",WS_OVERLAPPEDWINDOW|WS_VISIBLE,0,0,400,400,NULL,
NULL,hInstance,NULL);





HMENU hmenuname=LoadMenu(hInstance,MAKEINTRESOURCE(MENU1));

SetMenu(hwnd,hmenuname);
hdc=GetDC(hwnd);
hwnd=CreateWindowEx(NULL,"button","asdas",WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON,100,100,200,24,hwnd,(HMENU)(1112),hInstance,NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);




while(TRUE)
{


if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{

if(msg.message==WM_QUIT)
{
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);

}





SelectObject(hdc,red_brush);

FillRect(hdc,&rect,red_brush);
Ellipse(hdc,10,10,30,30);


}
DeleteObject(red_brush);

ReleaseDC(hwnd,hdc);
return(0);
}

Share this post


Link to post
Share on other sites