Computing.Net > Forums > Programming > windows programming

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

windows programming

Reply to Message Icon

Name: saddam (by lurker)
Date: May 2, 2004 at 21:56:08 Pacific
Comment:

hello,

as a beginner in windows user interface, can someone explain what does the CALLBACK function do in windows? could you also explain the difference between HINSTANCE and HANDLE?



Sponsored Link
Ads by Google

Response Number 1
Name: bhupi
Date: May 2, 2004 at 22:35:26 Pacific
Reply:

Please have a look at the following website. It should clear most of ur doubts.

http://www.mangovision.com/vbapi/articles/intro/index.html

Bhupi


0

Response Number 2
Name: saddam (by lurker)
Date: May 3, 2004 at 02:31:23 Pacific
Reply:

oh, i forgot to mention i intend to program using C not visual basic like:

int WinMain(.....)
{
......
}


0

Response Number 3
Name: Fozzie
Date: May 3, 2004 at 21:56:47 Pacific
Reply:

HINSTANCE declares a variable to be a handle to the instance of your program that is currently running. For example, when you start Notepad on a computer running Windows, a handle to that specific instance of Notepad is created. If you double click again on the Notepad link, another Notepad window opens along side the one that is already open. This is another instance of Notepad and there is now a new handle to this instance. Other programs, or Windows can refer to either instance of Notepad by using the appropriate handle to whichever instance neccessary.

HANDLE declares a variable that will be assigned the handle of a window. It could be the main application window or a status bar or a toolbar or probably several other types of windows.

That is my understanding of it anyway.

Not quite so sure on CALLBACK procedures but I'm not gonna let that stop me from acting like I know what I'm talking about. 8)

CALLBACK procedures are functions defined to handle the messages that will be dispatched to the appropriate windows (using their handles) when the user clicks on different parts of them or enters keyboard commands. I'm not sure why it has to be defined with the term CALLBACK.


0

Response Number 4
Name: saddam (by lurker)
Date: May 4, 2004 at 16:11:07 Pacific
Reply:

thanks for the info....can someone give me a CALLBACK example?


0

Response Number 5
Name: Fozzie
Date: May 5, 2004 at 15:36:15 Pacific
Reply:

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
// hwnd is the window recieving the message
// msg is the message

// wParam and lParam are double byte word
// values that can be passed in to your
// procedure. (I think that's correct terminology)
// Both lParam & wParam consist of both a
// high order word and a low word value.
// access using LOWORD(wParam) for example.
// two bytes for each parameter, a byte being
// 8 bits, four bytes total equals 32 bits.
// Hence 32bit Windows.

{
switch(msg) //then handle your msg
{
case WM_CREATE:
{
// WM_CREATE is sent to your procedure
// when your window is created.
// Windows creates the window for you
// but if you want you can also perform
// other commands here when your window opens

}
break;
case WM_CLOSE:
{
// Sent to your window when the user closes
// it. Again you don't have to do anything
// here, but usually you will want to tie up
// loose ends when a window closes.
}
break;
}
return 0;

}

Check the Windows API programming reference to learn about the other commands that can be handled by your procedure.


0

Related Posts

See More



Response Number 6
Name: Fozzie
Date: May 5, 2004 at 15:38:57 Pacific
Reply:

For a good tutorial on Windows programming using C try the following link.

http://www.winprog.org/tutorial/

That's where I learned most of what I know.


0

Sponsored Link
Ads by Google
Reply to Message Icon

C + + newb looking for an... nested ifs C++



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: windows programming

Windows Programming www.computing.net/answers/programming/windows-programming/11937.html

windows programming with Visual C++ www.computing.net/answers/programming/windows-programming-with-visual-c/5849.html

VC++ Windows Programming Book www.computing.net/answers/programming/vc-windows-programming-book/5173.html