Autor Beitrag
NTcomputer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33

Windows 7 x64
Delphi 2005 PE
BeitragVerfasst: So 31.05.09 17:42 
Ich versuche in den folgenden Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.MessageSucces(text:string);
var MsgBoxParams:TMsgBoxParams;
begin
  MsgBoxParams.cbSize := SizeOf(TMsgBoxParams);
  MsgBoxParams.hwndOwner := Self.Handle;
  MsgBoxParams.hInstance := GetWindowLong(Self.Handle, GWL_HINSTANCE);
  MsgBoxParams.lpszText := PChar(text);
  MsgBoxParams.lpszCaption := 'Vorgang erfolgreich beendet';
  MsgBoxParams.lpszIcon:= ///hier das Icon
  MsgBoxParams.dwStyle := MB_USERICON or MB_OK;
  MessageBoxIndirect(MsgBoxParams);
end;


ein eigenes Icon einzubauen, was ja normalerweise über MAKEINTRESOURCE(RESOURCEID) kein Problem ist.
Nur habe ich das Icon nicht in der Unit sondern in einer externen DLL als Resource.
Das Laden des Icons aus der Resource in ein TIcon der Unit funktioniert, nur was muss ich jetzt dem MsgBoxParams.lpszIcon zuweisen, damit er auch das Icon anzeigt??

Hoffe mir kann jemand helfen!


Moderiert von user profile iconNarses: Topic aus VCL (Visual Component Library) verschoben am So 31.05.2009 um 23:56
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 31.05.09 17:52 
Da musst du als Instanz das Modul angeben, du musst also die DLL laden und deren Handle dann als Instanz angeben, der Rest sollte dann normal funktionieren, indem du den Namen der Ressource angibst.

Ausprobiert habe ich das nicht, aber so würde ich es vermuten.

// EDIT:
Dazu steht ja auch was in der Dokumentation...
msdn.microsoft.com/e...ibrary/ms645402.aspx
NTcomputer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33

Windows 7 x64
Delphi 2005 PE
BeitragVerfasst: So 31.05.09 18:26 
Danke für deine schnelle Antwort,
ich vermute, du meinst das so?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
var
  MsgBoxParams:TMsgBoxParams;
  dllres:HINST;
begin
  dllres:=LoadLibrary(PChar(ExtractFilePath(ParamStr(0))+'imageres.dll'));
  MsgBoxParams.cbSize := SizeOf(TMsgBoxParams);
  MsgBoxParams.hwndOwner := self.Handle;
  MsgBoxParams.hInstance := GetWindowLong(dllres, GWL_HINSTANCE);
  MsgBoxParams.lpszText := PChar(text);
  MsgBoxParams.lpszCaption := 'Vorgang erfolgreich beendet';
  MsgBoxParams.lpszIcon:=MAKEINTRESOURCE(101);
  MsgBoxParams.dwStyle := MB_USERICON or MB_OK;
  MessageBoxIndirect(MsgBoxParams);
  FreeLibrary(dllres);
end;


Das klappt nur nicht richtig, keine Ahnung wieso, aber er nimmt das 101. Standardicon (glaube ich), jedenfalls nicht das was in der DLL ist. Muss ich das Handle noch irgendwie anders angeben?
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 01.06.09 00:36 
MsgBoxParams.hInstance :=dllres;
Probier es mal so.
NTcomputer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33

Windows 7 x64
Delphi 2005 PE
BeitragVerfasst: Mo 01.06.09 09:55 
Danke!