by Daywalker » Jun 27, 2001 @ 1:33pm
No, what i posted wasnt the Hello World example.<br>The main sourcecode of the hello worls example is this:<br><br><br>// sdf.cpp : Defines the entry point for the application.<br>//<br><br>#include "stdafx.h"<br>#include "sdf.h"<br>#include <commctrl.h><br><br>#define MAX_LOADSTRING 100<br><br>// Global Variables:<br>HINSTANCE hInst; // The current instance<br>HWND hwndCB; // The command bar handle<br><br>// Forward declarations of functions included in this code module:<br>ATOM MyRegisterClass (HINSTANCE, LPTSTR);<br>BOOL InitInstance (HINSTANCE, int);<br>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);<br>LRESULT CALLBACK About (HWND, UINT, WPARAM, LPARAM);<br><br>int WINAPI WinMain( HINSTANCE hInstance,<br> HINSTANCE hPrevInstance,<br> LPTSTR lpCmdLine,<br> int nCmdShow)<br>{<br> MSG msg;<br> HACCEL hAccelTable;<br><br> // Perform application initialization:<br> if (!InitInstance (hInstance, nCmdShow)) <br> {<br> return FALSE;<br> }<br><br> hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SDF);<br><br> // Main message loop:<br> while (GetMessage(&msg, NULL, 0, 0)) <br> {<br> if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) <br> {<br> TranslateMessage(&msg);<br> DispatchMessage(&msg);<br> }<br> }<br><br> return msg.wParam;<br>}<br><br>//<br>// FUNCTION: MyRegisterClass()<br>//<br>// PURPOSE: Registers the window class.<br>//<br>// COMMENTS:<br>//<br>// It is important to call this function so that the application <br>// will get 'well formed' small icons associated with it.<br>//<br>ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)<br>{<br> WNDCLASS wc;<br><br> wc.style = CS_HREDRAW | CS_VREDRAW;<br> wc.lpfnWndProc = (WNDPROC) WndProc;<br> wc.cbClsExtra = 0;<br> wc.cbWndExtra = 0;<br> wc.hInstance = hInstance;<br> wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SDF));<br> wc.hCursor = 0;<br> wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);<br> wc.lpszMenuName = 0;<br> wc.lpszClassName = szWindowClass;<br><br> return RegisterClass(&wc);<br>}<br><br>//<br>// FUNCTION: InitInstance(HANDLE, int)<br>//<br>// PURPOSE: Saves instance handle and creates main window<br>//<br>// COMMENTS:<br>//<br>// In this function, we save the instance handle in a global variable and<br>// create and display the main program window.<br>//<br>BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)<br>{<br> HWND hWnd;<br> TCHAR szTitle[MAX_LOADSTRING]; // The title bar text<br> TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name<br><br> hInst = hInstance; // Store instance handle in our global variable<br> // Initialize global strings<br> LoadString(hInstance, IDC_SDF, szWindowClass, MAX_LOADSTRING);<br> MyRegisterClass(hInstance, szWindowClass);<br><br> LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);<br> hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE,<br> CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);<br><br> if (!hWnd)<br> { <br> return FALSE;<br> }<br><br> ShowWindow(hWnd, nCmdShow);<br> UpdateWindow(hWnd);<br> if (hwndCB)<br> CommandBar_Show(hwndCB, TRUE);<br><br> return TRUE;<br>}<br><br>//<br>// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)<br>//<br>// PURPOSE: Processes messages for the main window.<br>//<br>// WM_COMMAND - process the application menu<br>// WM_PAINT - Paint the main window<br>// WM_DESTROY - post a quit message and return<br>//<br>//<br>LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)<br>{<br> HDC hdc;<br> int wmId, wmEvent;<br> PAINTSTRUCT ps;<br> TCHAR szHello[MAX_LOADSTRING];<br><br> switch (message) <br> {<br> case WM_COMMAND:<br> wmId = LOWORD(wParam); <br> wmEvent = HIWORD(wParam); <br> // Parse the menu selections:<br> switch (wmId)<br> {<br> case IDM_HELP_ABOUT:<br> DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);<br> break;<br> case IDM_FILE_EXIT:<br> DestroyWindow(hWnd);<br> break;<br> default:<br> return DefWindowProc(hWnd, message, wParam, lParam);<br> }<br> break;<br> case WM_CREATE:<br> hwndCB = CommandBar_Create(hInst, hWnd, 1); <br> CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);<br> CommandBar_AddAdornments(hwndCB, 0, 0);<br> break;<br> case WM_PAINT:<br> RECT rt;<br> hdc = BeginPaint(hWnd, &ps);<br> GetClientRect(hWnd, &rt);<br> LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);<br> DrawText(hdc, szHello, _tcslen(szHello), &rt, <br> DT_SINGLELINE | DT_VCENTER | DT_CENTER);<br> EndPaint(hWnd, &ps);<br> break;<br> case WM_DESTROY:<br> CommandBar_Destroy(hwndCB);<br> PostQuitMessage(0);<br> break;<br> default:<br> return DefWindowProc(hWnd, message, wParam, lParam);<br> }<br> return 0;<br>}<br><br>// Mesage handler for the About box.<br>LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)<br>{<br> RECT rt, rt1;<br> int DlgWidth, DlgHeight; // dialog width and height in pixel units<br> int NewPosX, NewPosY;<br><br> switch (message)<br> {<br> case WM_INITDIALOG:<br> // trying to center the About dialog<br> if (GetWindowRect(hDlg, &rt1)) {<br> GetClientRect(GetParent(hDlg), &rt);<br> DlgWidth = rt1.right - rt1.left;<br> DlgHeight = rt1.bottom - rt1.top ;<br> NewPosX = (rt.right - rt.left - DlgWidth)/2;<br> NewPosY = (rt.bottom - rt.top - DlgHeight)/2;<br> <br> // if the About box is larger than the physical screen <br> if (NewPosX < 0) NewPosX = 0;<br> if (NewPosY < 0) NewPosY = 0;<br> SetWindowPos(hDlg, 0, NewPosX, NewPosY,<br> 0, 0, SWP_NOZORDER | SWP_NOSIZE);<br> }<br> return TRUE;<br><br> case WM_COMMAND:<br> if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))<br> {<br> EndDialog(hDlg, LOWORD(wParam));<br> return TRUE;<br> }<br> break;<br> }<br> return FALSE;<br>}<br><br><br>But there are many other files (resources,...).<br>What should be wrong with my other sourcecode?<br><br><br><br>