Resourcen
-
Wie kann ich Resourcendateien mit dem C++Builder6 in WinAPI-Programmen verwenden??? Ich benutze den Resource Builder 2.0 von ...ähm... www.sicomponents.com
Hier erst mal der Code von meinem Prog://--------------------------------------------------------------------------- #include <windows.h> #include <commctrl> #pragma hdrstop //--------------------------------------------------------------------------- #pragma resource "C:\\ISI.RES" #pragma argsused long __stdcall OnMessage(HWND hwnd, UINT mes, UINT wParam, long lParam) { switch(mes) { case WM_CREATE: break; case WM_DESTROY: PostQuitMessage(wParam);break; case WM_COMMAND: switch(wParam){ } default: return DefWindowProc(hwnd, mes, wParam, lParam); } return 0; } WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { LPCSTR a = "ISI"; HWND hwnd; MSG msg;WNDCLASS cls; memset(&cls, 0, sizeof cls); cls.style = CS_HREDRAW | CS_VREDRAW; cls.cbWndExtra = 2; cls.hInstance = hInstance; cls.hIcon = LoadIcon(hInstance, "MAINICON"); cls.hCursor = LoadCursor(0, IDC_ARROW); cls.hbrBackground = HBRUSH(COLOR_BTNFACE + 1); cls.lpszClassName = a; cls.lpfnWndProc = OnMessage; if(!RegisterClass(&cls)) return 1; hwnd = CreateDialog(hInstance, a, 0, 0); if(!hwnd) return 1; InitCommonControls(); ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(GetMessage(&msg, 0, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } //---------------------------------------------------------------------------Weiß jemand wo der Fehler liegt?

Aber wenn ich statt hwnd = CreateDialog ...hwnd = CreateWindowEx(0, a, a, cls.style | WS_SYSMENU, 100, 100, 500, 300, 0, 0, hInstance, 0);mache, klappt es, aber nicht so wie ich das will! (Mit CreateWindowEx kann ich zwar auch die Controls draufpapen, aber das ist mir zu umständlich) HÄÄÄÄ?

Hier noch der Code der Datei C:\ISI.RC:/********************************************* File: C:\ISI.RC Generated by Resource Builder 2.0. *********************************************/ // Below are important 3 lines, don't change them! /* OutputExt=res */ DIALOG_0 DIALOG 0, 0, 160, 70 STYLE DS_SETFONT |WS_POPUP |WS_CAPTION |WS_VISIBLE |WS_HSCROLL |WS_SYSMENU |WS_THICKFRAME |WS_MAXIMIZEBOX |WS_MINIMIZEBOX CLASS "EASYISGOOD" CAPTION "Easy is good" FONT 8, "Tahoma" LANGUAGE LANG_NEUTRAL, 0 BEGIN CONTROL "Knuddeln!",100,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,46,26,50,14 END
-
OOPS!

Sollte das Prog bei der Zeile mit #pragma resource... hängen bleiben,
einfach die RES/RC-Datei zum Projekt hinzufügen.
-
Aiju schrieb:
LPCSTR a = "ISI"; hwnd = CreateDialog(hInstance, a, 0, 0);Hier noch der Code der Datei C:\ISI.RC:
DIALOG_0 DIALOG 0, 0, 160, 70 // [...]Ich nehme mal an, dass du irgendwo DIALOG_0 als Konstante definiert hast - nur warum verwendest du dann bei CreateDialog "ISI" und nicht MAKEINTRESOURCE(DIALOG_0)

Außerdem musst du eine DialogProc angeben
-
Und auch hier:
WinAPI.net: Gerüst für einen modalen Dialog