-
Win32 API Help
i recently bought M$-Visual C++ and i think it's great (i dont know if it's the best IDE though...) anyways...i've basically been working in Metroworks's CodeWarrior and this is big step up because it allows for win32 apps which im pretty unfamiliar with. does anyone have a win32 tut explaining the win32 api's embedded with m$vc++??? im having the HARDEST time understanding the autogenerated code here...thanks
-
Hmm you've bought from MS..... Allright that's an option. Search trough the MSDN documents on the internet. http://www.msdn.com. or look at http://www.gamedevelopers.com for some WIN32 programming information.
-
-
I have experince with Win32 C/C++ programming but not with MS Visual C++. I use Dev-C++
I learned alot from www.winprog.org and visit frequently, they have an irc channel, #winprog and there are some very intelectual Win32 coders there. Their Faq was also a fascinateing read.
Also came across foosyerdoos http://www.foosyerdoos.fsnet.co.uk/
They also have alot of examples, compatible with msvc++ very interesting
-
the API comments and source generated by VC++ is a jumbled mess to the newbie. I suggest reading up and learning how to create a "skeleton" app first. Beware, WIN32 api is extremely difficult and I suggest not wasting your time and use MFC.
Madman
-
thanks guys...i'll take a look at those sources.
-
/********** A little VC++ program example explained with comment by CleanBash ************/
#define WIN32_LEAN_AND_MEAN // trim the excess fat from Windows
#include <windows.h> // main windows headers
/************************************
Windows Procedure event handler
************************************/
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT paintstruct;
HDC hDC; // device context
char string[] = "Hello World!"; // text to be displayed
switch(message)
{
case WM_CREATE: // window is being created
return 0;
break;
case WM_CLOSE: // window is closing
PostQuitMessage(0);
return 0;
break;
case WM_PAINT:
hDC = BeginPaint(hwnd, &paintStruct);
// set text color to blue
SetTextColor(hDC, COLORREF(0x00FF0000));
// display text in middle of window
TextOut(hDC, 150, 150, string, sizeof(string)-1);
EndPaint(hwnd, &paintStruct);
return 0;
break;
default:
break;
}
return (DefWindowProc(hwnd, message, wParam, lParam));
}
/************************************
Main entry point of the program
************************************/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX windowClass; // window class
HWND hwnd; // window handle
MSG msg; // message
bool done; // flag saying when your app is complete
// fill out the window class structure
windowClass.cbSize = sizeof(WNDCLASSEX);
windowClass.style = CS_HREDRAW | CS_VREDRAW;
windowClass.lpfnWndProc = WndProc;
windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.hInstance = hInstance;
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = "MyClass";
windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
// register the window class
if (!RegisterClassEx(&windowClass))
return 0;
// class registered, so now create a window
hwnd = CreateWindowEx(NULL, // extended style
"MyClass", // class name
"Simple WIN32 program", // app name
WS_OVERLAPPEDWINDOW |
WS_VISIBLE | // window style
WS_SYSMENU,
100, 100, // x en y coordinate
400, 400, // width, height
NULL, // handle to parent
NULL, // handle to menu
hInstance, // application instance
NULL); // no extra params
// Check if window creation failed (hwnd would equal NULL)
if (!hwnd)
return 0;
done = false; // Initialize loop condition variabele
// main message loop
while (!done)
{
PeekMessage(&msg, hwnd, NULL, NULL, PM_REMOVE);
if (msg.message == WM_QUIT) // do you receive a quit-message?
{
done = true; // if so, time to quit the application
}
else
{
TranslateMessage(&msg); // translate message and dispatch to event queue
DispatchMessage(&msg);
}
}
return msg.wParam;
}
-
IMHO the MFC api sucks..
it's realy weird in a lot of ways things like UpdateData( TRUE ); and UpdateData( FALSE ); to read values from the interface into variables..
the QtApi from trolltech is a lot easier and can easily be crosscompiled between Windows, MacosX and Unix/Linux
Qt is free for non-profit use and not too expencive for commercial use.
If you want to try (windows) software using Qt, take a look @ Opera or Adobe Photoshop
also it plugs right into your MS VC++
-
Are you out of your mind. The MFC wrapper classes are an exact replica of the WIN32 api. If OO programming is too hard for you than I can see why you might say such a thing. Also, take a look at that previous WIN32 script and then generate a MFC skeleton and you will see the difference.
Madman