Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

C++ Gui Programming Using Win32

Win32 c++ API

  • Please log in to reply
2 replies to this topic

#1 C0BRA

C0BRA

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts
  • Learning:C, Java, C++, C#, Delphi/Object Pascal

Posted 25 July 2012 - 09:45 PM

I am trying to learn to code up GUI's without any IDE in C++, by using the Win32 APIs and using internet based resources.
I've coded up a small peice of code that seems to compile well but on execution doesn't show the window that I intended to create.
It executes and the automatically terminates & I see nothing on the screen.

Attached File  Window.cpp   1.51KB   126 downloads

The Constants and related variables are declared in a respective header file, which for some reason I was not allowed to upload.

Expecting some help on this issue, need to know where I am going wrong :)

-C0BRA
  • 0

#2 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 26 July 2012 - 02:31 AM

Hello COBRA, Welcome to CodeCall!

Are you sure the files are compiled successfully for you? If yes, modify your WindowProcedure method as
LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT uMsg, LPARAM lParam, WPARAM wParam)
{
switch(uMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_CLOSE:
SendMessage(hWnd, WM_DESTROY, 0, 0);
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
.

You can write (copy/paste your code into code tag) here and we can see it or you can upload after zipping them.

However, I suggest you better create the a default 'Win 32 Project' (the code that is created by the template) and see the code there.
  • 1

#3 C0BRA

C0BRA

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts
  • Learning:C, Java, C++, C#, Delphi/Object Pascal

Posted 26 July 2012 - 04:22 AM

Thank you kernelcoder, I see that I missed a return statement in the WindowProcedure.
But now that I add it, it doesn't seem to make any difference to the behaviour of the code.
The same problem occurs.

Just for information, I am using MSVC 2010.

Thanx for the response though :)
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download