14. august 2004 - 21:57Der er
7 kommentarer og 1 løsning
Program i taskbar
Jeg har nedenstående kode, som gør, at mit program ikke vises i taskbaren. Hvordan kan jeg gøre således, at jeg kan skifte mellem at programmet skal vises i min taskbar, ved f.eks at bruge en checkbutton?
begin ShowWindow(Application.Handle, SW_HIDE) ; SetWindowLong(Application.Handle, GWL_EXSTYLE, getWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW) ; ShowWindow(Application.Handle, SW_SHOW) ; end;
Ok, jeg fandt faktisk selv ud af noget, men har stadig brug for en hjælpende hånd.
procedure Taskbar; begin ShowWindow(Application.Handle, SW_HIDE) ; SetWindowLong(Application.Handle, GWL_EXSTYLE, getWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW) ; ShowWindow(Application.Handle, SW_SHOW) ; end;
procedure TForm1.CheckBox1Click(Sender: TObject); begin if Checkbox1.checked = true then begin Taskbar end else if Checkbox1.Checked = false then begin ; end; end; end.
Hvad skal jeg skrive ved det sidste 'then begin', for at den disabler proceduren Taskbar? :)
Synes godt om
Slettet bruger
14. august 2004 - 22:49#2
Prøv med:
procedure ShowInTaskbar; begin SetWindowLong(Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) and not WS_EX_TOOLWINDOW); ShowWindow(Application.Handle, SW_SHOW) ; end;
procedure Taskbar; begin ShowWindow(Application.Handle, SW_HIDE) ; SetWindowLong(Application.Handle, GWL_EXSTYLE, getWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW) ; ShowWindow(Application.Handle, SW_SHOW) ; end;
procedure TForm1.CheckBox1Click(Sender: TObject); begin if Checkbox1.checked = true then Taskbar else if Checkbox1.Checked = false then ShowInTaskbar; end; end;
du skal bare gemme den gamle fra SetWindowLong når du fjerner den
var oldwl : Longint;
procedure ShowInTaskbar(Show : Boolean); const SW : array[Boolean] of Cardinal = (SW_HIDE, SW_SHOW); begin ShowWindow(Application.Handle, SW[Show]);
if Show then SetWindowLong(Application.Handle, GWL_EXSTYLE, oldwl) else oldwl := SetWindowLong(Application.Handle, GWL_EXSTYLE, getWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW); end;
procedure TForm1.Button1Click(Sender: TObject); begin ShowInTaskbar(Checkbox1.Checked); end;
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.