السلام عليكم ورحمة الله وبركاته
أنا أعمل على الديلفي وأود أن أتعلم الـ C++ فأرجو منكم مساعدتي فأنا لا أعرف أي شئ عن هذه اللغة سوى أنها قوية جدا
لدي عدة أسئلة أرجو التكرم بالإجابة عنها :
1-ما هي مهمة ملف الـ *.h
2-كيف يمكن تعريف مكتبة على الـ C++ واستخدامها في أحد البرامج
3-كنت أحاول تطبيق أحد الدروس وهو عبارة عن إنشاء نافذة فقط ولكن عندما أضغط Ctrl+F5 يعطي رسالة بوجود خطأ واحد
أرجو المساعدة في معرفة مكان هذا الخطأ ولكم جزيل الشكر
ملاحظة :
اسم المشروع لدي ( Win32 ) وهو من نوع : Win32 Applaication ثم اخترت
A Simple Win32 Application
كتبت الكود في الملف : Win32.cpp
البرنامج :
//Win32.CPP
#include
#include
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
PSTR szCmdLine, // pointer to command line
int iCmdShow // show state of window
) {
// STEP #1 - Set up your variables ------------------------------------
WNDCLASSEX wndclass;
MSG msg;
HWND hwnd
static char szAppName[] = "First Windows Program";
// STEP #2 - Set Elements of a "WNDCLASSEX" structure
wndclass.cbSize = sizeof (wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
// STEP #3 - Register the "WNDCLASSEX" structure with the operating
// system
if (!(RegisterClassEx (&wndclass)))
return FALSE;
// STEP #4 - Now you can actually create the window
hwnd = CreateWindowEx (
WS_EX_APPWINDOW,
szAppName, "Skelo32",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
// STEP #5 - Display the window
ShowWindow (hwnd, iCmdShow);
// STEP #6 - Force an update to the window
UpdateWindow (hwnd);
// Step #7 - The WinMain function enters an infinite loop which is referred
// to as a windows "message pump"
while (TRUE)
{
if (!GetMessage (&msg, NULL, 0, 0))
return msg.wParam;
TranslateMessage (&msg);
DispatchMessage (&msg);
} }
// Step #8 - The windows callback function "WinProc"
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM
wParam, LPARAM lParam)
{
// Step # 9 WinProc - Define variables
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
static BOOL fFirstPaint = TRUE;
// Step # 10 WinProc - The switch statement for handling windows messages
switch (iMsg)
{
case WM_KEYDOWN :
switch (wParam)
{
case VK_ESCAPE:
case VK_F12:
PostMessage (hwnd, WM_CLOSE, 0, 0);
return 0;
}
return 0;
case WM_PAINT :
hdc = BeginPaint (hwnd, &ps);
GetClientRect (hwnd, &rect);
DrawText (hdc, "Hello World!!", -1, &rect, DT_SINGLELINE |
DT_CENTER | DT_VCENTER);
EndPaint (hwnd, &ps);
if (fFirstPaint)
{
ShowCursor (TRUE);
fFirstPaint = FALSE;
}
return 0;
case WM_DESTROY :
PostQuitMessage (0);
return 0;
}
return DefWindowProc (hwnd, iMsg, wParam, lParam);
}