Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi MessageBoxIndirect eigenes Symbol (https://www.delphipraxis.net/76093-messageboxindirect-eigenes-symbol.html)

Colt Storm 29. Aug 2006 19:49


MessageBoxIndirect eigenes Symbol
 
Ich wollte mit MessageBoxIndirect eine MessageBox mit eigenem Symbol machen, alles funktioniert, nur es kommt nicht mein Symbol...

Delphi-Quellcode:
var
  params: MSGBOXPARAMS;
begin
  with params do begin
    cbSize := SizeOf(TMsgBoxParams);
    dwContextHelpId := 0;
    dwLanguageId := LANG_NEUTRAL;
    dwStyle := MB_OK or MB_USERICON;
    hInstance := GetWindowLong(Handle, GWL_HINSTANCE);
    hwndOwner := Handle;
    lpfnMsgBoxCallback := nil;
    lpszCaption := 'blubb';
    lpszIcon := 'MAINICON';
    lpszText := 'blubb';
  end;
  MessageBoxIndirect(params);
end;
Das Icon MAINICON ist in der Anwendung vorhanden, hab extra mit dem ResourceHacker nachgeguckt, müsste also doch eigentlich alles so in Ordnung sein...

Was mach ich da falsch?

Zacherl 29. Aug 2006 19:55

Re: MessageBoxIndirect eigenes Symbol
 
Du musst LoadRessource('MainIcon') oder so ähnlich verwenden ...

Daniel G 29. Aug 2006 19:59

Re: MessageBoxIndirect eigenes Symbol
 
Ja, so ähnlich :mrgreen:

Hab' Müll verzapft. :wall:

Zacherl 29. Aug 2006 20:04

Re: MessageBoxIndirect eigenes Symbol
 
Wenn du dein Icon über einen Index einbindest (Mainicon ist meine ich 1), dann kannst du das verwenden:
Delphi-Quellcode:
function MyMessageBox(hWnd: HWND; Text, Caption: String; IconID: DWORD;
  const Buttons: Cardinal = MB_OK): Integer;
var MsgInfo: TMsgBoxParams;
begin
  With MsgInfo do
  begin
    cbSize := SizeOf(TMsgBoxParams);
    dwContextHelpId := 0;
    dwLanguageId := LANG_NEUTRAL;
    dwStyle := Buttons or MB_USERICON or MB_APPLMODAL;
    hInstance := GetWindowLong(hWnd, GWL_HINSTANCE);
    hwndOwner := hWnd;
    lpfnMsgBoxCallback := nil;
    lpszCaption := @Caption[1];
    lpszIcon := MAKEINTRESOURCE(IconID);
    lpszText := @Text[1];
  end;
  Result := Integer(MessageBoxIndirect(MsgInfo));
end;
Florian

Colt Storm 29. Aug 2006 20:11

Re: MessageBoxIndirect eigenes Symbol
 
Danke schonmal für die Hilfe, nur leider hat das alles nicht geklappt :(

Habs mit MAKEINTRESOURCE(1); und auch mit MAKEINTRESOURCE(0); versucht, ging beides nicht :(


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:01 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz