CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Feb 2008
    Posts
    2

    Cool Events on WinApi C++

    Hello there.

    I am using Visual C++ Express right now.

    I dont want to make applications throught the automated processes that this pack offers me, cause application gets much larger than they should have bin.

    Yesterday I made my first step on WinApi: this is the result.

    Code:
    #include <windows.h>
    
    
    char* App_Title = "Skoumas and the brains at the kangela";
    
    
    LRESULT WINAPI myProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 
    
    {
    
    	if(message == WM_CLOSE) {
    	
    		int apantisi;
    		apantisi = MessageBox(NULL, "Are you Sure?",App_Title,1);
    
    		if (apantisi==1)  
    		PostQuitMessage(0);
    
    		
    	}
    	return 0;
    }
    
    LRESULT WINAPI myProcbutton(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 
    
    {
    
    	if(message == 1) {
    	
    		int apantisi;
    		apantisi = MessageBox(NULL, "Are you Sure?",App_Title,1);
    
    		if (apantisi==1)  
    		PostQuitMessage(0);
    
    		
    	}
    	return 0;
    }
    
    
    int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    
    {
    MSG msg;
    
    
    	HWND myDialog=CreateWindowEx(0, WC_DIALOG, App_Title, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
    		600, 100, 400, 200, NULL, NULL,NULL,NULL 
    	);
    
    	HWND button1=CreateWindowEx(	0,"BUTTON",	"My Button",BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
    		50,50,100,25,myDialog,NULL,NULL,NULL
    
    	);
    
    	
    SetWindowLong(myDialog,	DWL_DLGPROC, (long) myProc);
    SetWindowLong(button1,	DWL_DLGPROC, (long) myProcbutton);
    
    
    	while(GetMessage(&msg,NULL,0,0)) 
    	{
    		TranslateMessage(&msg);
    		DispatchMessage(&msg); 
    
    	} 
    
    
    	return 0;
    
    }
    ------------------------------------------------------

    In this code you can see that the program generates a simple window and a button inside it.

    I want to be able when i press the button to show a message box.

    Can you please help me?
    Last edited by skoumas; February 22nd, 2008 at 10:15 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured