nanogui: A one button program


Previous by date: 7 Sep 2000 16:45:48 -0000 Re: Multiple Mwin Apps, Greg Haerr
Next by date: 7 Sep 2000 16:45:48 -0000 Re: Multiple Mwin Apps, Rob Taylor
Previous in thread:
Next in thread: 7 Sep 2000 16:45:48 -0000 Re: A one button program, Marek Peca

Subject: A one button program
From: "Alfredo Masias" ####@####.####
Date: 7 Sep 2000 16:45:48 -0000
Message-Id: <NEBBJKFABIGEJJJJPNAAEEECCAAA.jamacias@quintron.com>

Hi.
I am having problems displaying a button on my form.  A blank empty for
shows up ok but no button.  My code follows below.  Do you see any problem
with it?
(It ran ok in VC++ just by changing WINAPI to APIENTRY)
Any hints will be deeply appreciated

Alfredo Macias
Quintron Systems
(805)928-4343

********************************************************
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
		LPARAM lParam);
HDC dc;
HWND button1;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
	LPSTR lpszCmdLine, int nCmdShow)

{
	WNDCLASS wc;
	HWND hWnd;
	MSG msg;
	wc.style = CS_HREDRAW|CS_VREDRAW|CS_BYTEALIGNCLIENT;
	wc.lpfnWndProc = WndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = NULL;
	wc.hCursor = LoadCursor(NULL,IDC_ARROW);
	wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = "ButtonExample";
	RegisterClass(&wc);
	hWnd = CreateWindow(wc.lpszClassName,"Using A Button",
	WS_OVERLAPPEDWINDOW,100,100,300,200,
	NULL,NULL,hInstance,NULL);
	button1 = CreateWindow("BUTTON","Hit Me",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
	90,50,120,40,hWnd,NULL,hInstance,NULL);
	ShowWindow(hWnd,nCmdShow);
	UpdateWindow(hWnd);
	while (GetMessage(&msg,NULL,0,0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
		LPARAM lParam){
	switch(uMsg){
		case WM_COMMAND:{
			if ((HWND)lParam==button1)
				MessageBox(hwnd,"Clicked!","Ooohhh",MB_OK);
			return 0;
		}
		case WM_DESTROY:{
			PostQuitMessage(0);
			break;
		}
		default:{
			return DefWindowProc(hwnd,uMsg,wParam,lParam);
		}
	}
	return 0;
}


Previous by date: 7 Sep 2000 16:45:48 -0000 Re: Multiple Mwin Apps, Greg Haerr
Next by date: 7 Sep 2000 16:45:48 -0000 Re: Multiple Mwin Apps, Rob Taylor
Previous in thread:
Next in thread: 7 Sep 2000 16:45:48 -0000 Re: A one button program, Marek Peca


Powered by ezmlm-browse 0.20.