PDA

Click to See Complete Forum and Search --> : Which is better to start with?


VIsualPenguin
Jan 31st, 2002, 09:36 AM
Which is bettor to start with? MFC or everything with API?

VisualPenguin

[Digital-X-Treme]
Jan 31st, 2002, 11:13 AM
I would say API.

CornedBee
Feb 1st, 2002, 06:54 AM
Definitely API, and everyone here will agree (well, almost everyone). You can later learn MFC too, if you really understand what's going on. You can make apps far quicker, but if you don't know it well you might get really lost. MFC is an advantage at a prize. (z or c?)

JoshT
Feb 1st, 2002, 11:22 AM
I got flamed once on a non-programming forum for suggesting to someone who wanted to learn Windows programming that the API is better than MFC...

parksie
Feb 1st, 2002, 11:47 AM
CB - price :)

Josh - ack, everyone knows API is better *smirk* Silly fools :p

kedaman
Feb 1st, 2002, 05:36 PM
API is functional and quite lowlevel, me and parksie decided to make an object oriented layer to it, but I'm too busy writing my own language right now :p the classes for the layer will then be compiled in BORK to a set of generic C++ classes that will be upwards compatible with BORK modules. By then you can choose to write your win32 application in C++ or BORK using the generated layer, and it will highly efficient compared to MFC ;)

made_of_asp
Feb 2nd, 2002, 04:44 AM
API = speed, control, runtimeless, you ONLY use what u want to, say you are using API functions

EnumWindows
CreateFont
CreateWindow
ReturnDlgProc

...or whatever

you WILL be realy using ONLY those API's, nothing more :)

MFC = easiness OR a bit of confustion, mess, +size, -control, runtimes :( DLL files

VIsualPenguin
Feb 2nd, 2002, 09:01 AM
can anybody then give me a realy simple program? with just the basic needs like one dialog, so I can find out how to make it myself?

VisualPenguin

made_of_asp
Feb 2nd, 2002, 09:41 AM
Visual C++


#include <windows.h>

LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);

char szWinNamw[] = "MyWin";



int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR kposzArgs, int nWinMode)

{

HWND hwnd;

MSG msg;

WNDCLASSEX wcl;

wcl.cbSize = sizeof(WNDCLASSEX);

wcl.hInstance = hThisInst;

wcl.lpszClassName = "My Window";

wcl.lpfnWndProc = WindowFunc;

wcl.style = 0;

wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);

wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO);

wcl.hCursor = LoadCursor(NULL, IDC_ARROW);

wcl.lpszMenuName = NULL;

wcl.cbClsExtra = 0;

wcl.cbWndExtra = 0;

wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);



if(!RegisterClassEx(&wcl)) return 0;



hwnd = CreateWindow( "My Window",

"Skeleton Window",

WS_OVERLAPPEDWINDOW,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

HWND_DESKTOP,

NULL,

hThisInst,

NULL );

ShowWindow(hwnd, nWinMode);

UpdateWindow(hwnd);



int i;

while(i = GetMessage(&msg, NULL, 0, 0))

{ if (i == -1) break;

TranslateMessage(&msg);

DispatchMessage(&msg);

}

return msg.wParam; }



LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

{

switch(message)

{

case WM_DESTROY:

PostQuitMessage(0);

break;

default:

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

}

return 0;

}

Zaei
Feb 2nd, 2002, 10:59 AM
Why did you double space that? It makes it look twice as long =).

You should also be handling WM_PAINT:

LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_PAINT:
ValidateRect(hwnd, NULL);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}


Otherwise, the window will continue to get WM_PAINT messages.

Z.

parksie
Feb 3rd, 2002, 06:15 AM
I thought DefWindowProc would handle that.

Glad to see that it's got the check for -1 in there ;)

Zaei
Feb 3rd, 2002, 02:47 PM
You dont have to ValidateRect, but you do have to return 0. GetMessage will leave WM_PAINT in the queue until there arent any more messages (i think that's what the docs said). I found this info under the GetMessage() docs, the WM_PAINT message docs and the "Designing a Window Procedure" topic, in the MSDN.

Z.