Einzelnen Beitrag anzeigen

Benutzerbild von Rastaman
Rastaman

Registriert seit: 6. Jan 2005
Ort: Lübbecke
575 Beiträge
 
Turbo C++
 
#1

[Non VCL] - Button erscheint nicht...

  Alt 11. Okt 2005, 09:08
Moin!
Hab jetz ma ernsthafter mit non VCL angefangen, weil mir C++ doch nich so liegt
Jetz teste ich rum hier mit non VCL und hab gleich n Prob.
Der Button erscheint einfach nicht.
Es soll n Fenster werden mit nem Button, beim Klick erscheint n About Dialog.
Funktioniert bis jetz nur das hauptfenster und der Button (sollte, tut er aber nicht).
Hier was ich bis jetzt habe:

Delphi-Quellcode:
program TestProg;

uses
  Windows,
  Messages;

var
  WndMain,
  WndAbout: TWndClassEx;
  //Fensterhandles
  hWndMain,
  hWndAbout: HWND;

  //Buttonhandles
  hBtnAbout: HWND;
  msg: TMSG;

function CreateButtons: Boolean;
begin
  hBtnAbout := CreateWindow('BUTTON', 'About',
                            WS_CHILD or WS_VISIBLE,
                            350, 270, 40, 24,
                            hWndMain, 0, 0, nil);
  Result := True;
end;

function WndMainProc(hwnd: HWND; uMsg: UINT; wParam: WPARAM;
                     lParam: LPARAM): LRESULT; stdcall;
begin
  case uMsg of
    WM_CREATE: if not CreateButtons then
                 PostQuitMessage(0);
  end;
  Result := DefWindowProc(hwnd, uMsg, wParam, lParam);
end;

function WndAboutProc(hwnd: HWND; uMsg: UINT; wParam: WPARAM;
                      lParam: LPARAM): LRESULT; stdcall;
begin
  Result := DefWindowProc(hwnd, uMsg, wParam, lParam);
end;

function RegisterWindowClasses: Boolean;
begin

  WndMain.cbSize := SizeOf(TWndClassEx);
  WndMain.style := CS_OWNDC;
  WndMain.lpfnWndProc := @WndMainProc;
  WndMain.cbClsExtra := 0;
  WndMain.cbWndExtra := 0;
  WndMain.hInstance := hInstance;
  WndMain.hCursor := LoadCursor(0, IDC_ARROW);
  WndMain.hbrBackground := COLOR_WINDOW;
  WndMain.lpszMenuName := nil;
  WndMain.lpszClassName := 'wnd_Root';
  RegisterClassEx(WndMain);

  WndAbout.cbSize := SizeOf(TWndClassEx);
  WndAbout.style := CS_OWNDC;
  WndAbout.lpfnWndProc := @WndAboutProc;
  WndAbout.cbClsExtra := 0;
  WndAbout.cbWndExtra := 0;
  WndAbout.hInstance := hInstance;
  WndAbout.hCursor := LoadCursor(0, IDC_ARROW);
  WndAbout.hbrBackground := COLOR_WINDOW;
  WndAbout.lpszMenuName := nil;
  WndAbout.lpszClassName := 'wnd_About';
  RegisterClassEx(WndAbout);

  Result := True;

end;

begin

  if not RegisterWindowClasses then
    Exit;

  hWndMain := CreateWindowEx(WS_EX_APPWINDOW,
                             'wnd_Root', 'Haupt Fenster',
                             WS_OVERLAPPED or WS_VISIBLE,
                             200, 300,
                             400, 400,
                             0, 0, hInstance, nil);

  while True do
  begin
    if not GetMessage(msg, 0, 0, 0) then
      break;
    TranslateMessage(msg);
    DispatchMessage(msg);
  end;

end.
Thx schonmal!
Chuck Norris has counted to infinity ... twice!
  Mit Zitat antworten Zitat