Jump to content

Help with Window app

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
sakishrist

sakishrist

    Programmer

  • Members
  • PipPipPipPip
  • 109 posts
Hello, I have this code. You can dounload it as zip from there. I have some questions.

1. Lines 9-10 winnie.CPP
int WINAPI WinMain

   (HINSTANCE hInst, HINSTANCE hPrevInst, char * cmdParam, int cmdShow)
Could you explane these arguments to me?

2. Lines 35 and 49 winnie.CPP
WinClass::WinClass
WinMaker::WinMaker
Why do we use " :: "? And also what is WinClass and WinMaker before the " :: " and what is it after that?

3. Line 68 winnie.CPP
LRESULT CALLBACK WindowProcedure 

    (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
What is LRESULT?

4. Lines 68-81 winnie.CPP
LRESULT CALLBACK WindowProcedure 

    (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

{

    switch (message)

    {

		// In this simple program, this is the only message we are processing

        case WM_DESTROY:

            ::PostQuitMessage (0);

            return 0; // return zero when processed


    }

	// All the unprocessed messages go there, to be dealt in some default way

    return ::DefWindowProc (hwnd, message, wParam, lParam );

}
What exactly hapens when the WM_DESTROY is processed? What does exactly ":: PostQuitMessage (0);" do?

Thanks!!! :)

#2
carly

carly

    Learning Programmer

  • Members
  • PipPipPip
  • 34 posts
It's basic Win32 api
See on specialized Win32 api ng news://comp.os.ms-windows.programmer.win32

#3
roboticforest

roboticforest

    Programmer

  • Members
  • PipPipPipPip
  • 110 posts
The double colon "::" is called the Scope Resolution Operator.

A quick Google search brings up this forum:
Scope Resolution Operator - C++
There is a fairly good explanation there of what it's for.

You can also find some information about it when searching for Namespaces, which I highly recommend that you do.

Everything else you asked is in the Windows API which I wouldn't be able to help you with.
Dave

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,713 posts
I'm not entirely sure why the :: is prefixed to WinAPI functions. I've never used it myself, and my programs work just fine.

PostQuitMessage is more or less the same as the C library exit() function, except it doesn't exit immediately.

#5
RobotGymnast

RobotGymnast

    Programmer

  • Members
  • PipPipPipPip
  • 143 posts
The :: is prefixed to specify that it's global.

LRESULT is just a long result. It's microsoft's funny way of returning values.

:: is the scope resolution operator.
For example, with WinMaker, WinMaker::WinMaker specifies it's constructor.

HINSTANCE hInst : The current instance we're using (If you don't know what this means, you don't need to care about it)
HINSTANCE hPrevInst: The previous instance we're using (you can use this to check to see if the program is currently running)
char * cmdParam: The paramaters if the program is started from the command prompt
int cmdShow : bah, I forget what this one is.

#6
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,713 posts
Correction: The hPrevInst parameter is always null under Win32 and cannot be used to check to see if the program is already running. In 16-bit Windows this was the case, but not anymore.

How to Identify a Previous Instance of an Application

nCmdShow takes either of two values: SW_SHOW or SW_HIDE. Pretty self-explanatory.