API WND (No Taskbar Button) How can I get rid of this button ? lazarus / 34-Windows ---------------------------------------------------------------------- RAW · 2017-10-20 17:33 Hi, can anybody give me a hint how to get rid of the taskbar button ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i PROGRAM project1; USES  Windows;  VAR  WND: TWndClass;  MSG: TMSG;  hWndMain : THandle;  hWndPopup: THandle;  CONST  HotKeyShow = 113000;  Function MainProc(hWnd, MSG: LongWord; wPARAM, lPARAM: LongInt): Integer; StdCall;  Begin   If (MSG = WM_HOTKEY) And (wPARAM = HotKeyShow)   Then    Begin     ShowWindow(hWndMain, SW_SHOW);     ShowWindow(hWndPopup, SW_SHOW);     SetForegroundWindow(hWndMain);   SetForegroundWindow(hWndPopup);    End;    Case MSG   Of    WM_Close: UnregisterHotKey(hWndMain, HotKeyShow);     WM_DESTROY:     Begin    PostQuitMessage(0);      Exit;     End;     WM_KEYDOWN:     Begin    If (VK_ESCAPE = wPARAM)      Then       Begin        ShowWindow(hWndMain, SW_HIDE);        ShowWindow(hWndPopup, SW_HIDE);       End;     End;     WM_LBUTTONDOWN: MessageBox                    (hWndMain, PChar('Left Mouse Button'), PChar('MyProgram'), 0);   End;   Result:= DefWindowProc(hWnd, MSG, wPARAM, lPARAM);  End; BEGIN WND.lpszClassName:= 'MyWND'; WND.lpfnWndProc  := @MainProc; WND.hInstance    := hInstance; WND.hbrBackground:= 5;  RegisterClass(WND);  hWndMain:= CreateWindow (WND.lpszClassName,'My API Window', WS_OVERLAPPEDWINDOW Or WS_VISIBLE,  500, 500, 500, 300, 0, 0, hInstance, Nil);  hWndPopup:= CreateWindow (WND.lpszClassName,'My Second Window', WS_EX_TOOLWINDOW Or WS_VISIBLE,  200, 500, 500, 300, hWndMain, 0, hInstance, Nil);  If Not RegisterHotKey(hWndMain, HotKeyShow, MOD_CONTROL, VK_BACK) Then MessageBox(hWndMain, PChar('HotKey Failed'), PChar('MyProgram'), 0);  While GetMessage(MSG, 0, 0, 0) Do  Begin   TranslateMessage(MSG);   DispatchMessage (MSG);  End;END. ---------------------------------------------------------------------- RAW · 2017-10-20 17:49 Maybe it's only possible with a hidden window ??? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i PROGRAM project1; USES  Windows;  VAR  WND: TWndClass;  MSG: TMSG;  hWndMain,  hWndPopup,  hWndHidden: THandle;  CONST  HotKeyShow = 113000;  Function MainProc(hWnd, MSG: LongWord; wPARAM, lPARAM: LongInt): Integer; StdCall;  Begin   If (MSG = WM_HOTKEY) And (wPARAM = HotKeyShow)   Then    Begin     ShowWindow(hWndMain, SW_SHOW);     ShowWindow(hWndPopup, SW_SHOW);     SetForegroundWindow(hWndMain);   SetForegroundWindow(hWndPopup);    End;    Case MSG   Of    WM_Close: UnregisterHotKey(hWndMain, HotKeyShow);     WM_DESTROY:     Begin    PostQuitMessage(0);      Exit;     End;     WM_KEYDOWN:     Begin    If (VK_ESCAPE = wPARAM)      Then       Begin        ShowWindow(hWndMain, SW_HIDE);        ShowWindow(hWndPopup, SW_HIDE);       End;     End;     WM_LBUTTONDOWN: MessageBox                    (hWndMain, PChar('Left Mouse Button'), PChar('MyProgram'), 0);   End;   Result:= DefWindowProc(hWnd, MSG, wPARAM, lPARAM);  End; BEGIN WND.lpszClassName:= 'MyWND'; WND.lpfnWndProc  := @MainProc; WND.hInstance    := hInstance; WND.hbrBackground:= 5;  RegisterClass(WND);  hWndHidden:= CreateWindow (WND.lpszClassName,'HIDDEN', WS_OVERLAPPEDWINDOW,  0, 0, 1, 1, 0, 0, hInstance, Nil);  hWndMain:= CreateWindow (WND.lpszClassName,'My API Window', WS_EX_TOOLWINDOW Or WS_VISIBLE,  500, 500, 500, 300, hWndHidden, 0, hInstance, Nil);  hWndPopup:= CreateWindow (WND.lpszClassName,'My Second Window', WS_EX_TOOLWINDOW Or WS_VISIBLE,  200, 500, 500, 300, hWndMain, 0, hInstance, Nil);  If Not RegisterHotKey(hWndMain, HotKeyShow, MOD_CONTROL, VK_BACK) Then MessageBox(hWndMain, PChar('HotKey Failed'), PChar('MyProgram'), 0);  While GetMessage(MSG, 0, 0, 0) Do  Begin   TranslateMessage(MSG);   DispatchMessage (MSG);  End;END. ---------------------------------------------------------------------- Leledumbo · 2017-10-20 18:30 2 requirements: WS_EX_TOOLWINDOW AND no owner. ---------------------------------------------------------------------- ASerge · 2017-10-20 18:48 Quote from: Leledumbo on October 20, 2017, 08:30:14 pm2 requirements: WS_EX_TOOLWINDOW AND no owner. WS_EX_TOOLWINDOW - it does not look like a normal window. Better hidden WS_EX_TOOLWINDOW, WS_POPUP as parent for main. ---------------------------------------------------------------------- ASerge · 2017-10-20 18:57 Quote from: RAW on October 20, 2017, 07:33:01 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i PROGRAM project1; USES  Windows;...Did you read this and this? QuoteExcept for reserved words and directives, which are in all lowercase, all Pascal identifiers should use InfixCaps, which means the first letter should be a capital, and any embedded words in an identifier should be in caps, as well as any acronym that is embedded ---------------------------------------------------------------------- RAW · 2017-10-20 21:58 Quote2 requirements: WS_EX_TOOLWINDOW AND no owner. Really ? I don't get it to work without a hidden window... QuoteWS_EX_TOOLWINDOW - it does not look like a normal window. Better hidden WS_EX_TOOLWINDOW, WS_POPUP as parent for main. Yes... a normal window looks better... I think I'll use this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  hWndHidden:= CreateWindow (WND.lpszClassName,'HIDDEN', WS_Popup,  0, 0, 1, 1, 0, 0, hInstance, Nil);  hWndMain:= CreateWindow (WND.lpszClassName,'My API Window', WS_OverlappedWindow Or WS_VISIBLE,  800, 500, 500, 300, hWndHidden, 0, hInstance, Nil);  hWndPopup:= CreateWindow (WND.lpszClassName,'My Second Window', WS_EX_AppWindow Or WS_VISIBLE,  200, 200, 200, 300, hWndMain, 0, hInstance, Nil); QuoteDid you read this and this? ... No, I don't... btw: there is something that I like, but also a lot that I don't like... For example: Why on earth does everybody use FName for a field? I guess it's very easy to see that a field is a field (VAR).  BUT if you send some code via email or post code on the internet or print some code etc... then I don't know what exactly FName is. I mean inside the LAZARUS IDE it's easy but even there I don't like to wait for the hint window. I like to see it right away: iName = Integer, strName = String, uStrName = UnicodeString, edtName = TEdit, pnlName = TPanel, ptName = TPoint .... etc. That's a lot better I think... and you cannot do so much mistakes if in a hurry...  btw: T for Type is ok, not perfect, but ok... Thanks to both of you... ---------------------------------------------------------------------- SunyD · 2017-10-20 22:47 If you want remove taskbar button, when your application is minimized then it is very easy. You can call the function Hide, it hides your form and taskbar button. You must call later the function show to show your form and taskbar button. Here is one example with trayicon. When you minimize the form then it will be hidden, you must click on its tastbar icon to show again. ---------------------------------------------------------------------- taazz · 2017-10-21 03:08 Quote from: RAW on October 20, 2017, 11:58:13 pmFor example: Why on earth does everybody use FName for a field? I guess it's very easy to see that a field is a field (VAR).  two main goals 1) I do not need to remember the name of the variable I just need to type F and the IDE will provide me with a list of variable to choose from and 2) I want to know when the algorithm touches non local things thos places are usually where most of logical bugs appear in my code. Quote from: RAW on October 20, 2017, 11:58:13 pmBUT if you send some code via email or post code on the internet or print some code etc... then I don't know what exactly FName is. I mean inside the LAZARUS IDE it's easy but even there I don't like to wait for the hint window. I like to see it right away: iName = Integer, strName = String, uStrName = UnicodeString, edtName = TEdit, pnlName = TPanel, ptName = TPoint .... etc. That's a lot better I think... and you cannot do so much mistakes if in a hurry...  I guess that depends on ones habits. For example I have never seen a Name or a phone that is not a string a position might be a tpoint or an integer depending who wrote it but that becomes apparent from the assignment code I'm more interested to be able to find faster what I'm looking for when I type than what it is. I see no value on what it is after the initial definition only on what it represents, that is why the name of the variable is a big deal and I avoid reusing variables. Logic errors are harder to find than data errors usually there are a couple of exceptions that data type will create logical errors in the code but very few. ---------------------------------------------------------------------- RAW · 2017-10-21 04:39 QuoteHere is one example with trayicon. When you minimize the form then it will be hidden, you must click on its tastbar icon to show again. Thanks... but right now I don't need the LCL, the target computer hasn't even a standard shell... Quote1) I do not need to remember the name of the variable I just need to type F and the IDE will provide me with a list of variable to choose from... OK, but I do the same... If I need an Integer then I type "i" and see all my integer variables or I type "str" and I see all my String variables, that's even better if the program has really a lot variables or fields...    AND I can directly see what kind of variable this is... especially outside the IDE. (I don't like compromises) ---------------------------------------------------------------------- ASerge · 2017-10-21 15:22 Quote from: RAW on October 20, 2017, 11:58:13 pm ... No, I don't... And in vain. This is your example, only the types have been changed to compile under Win64 (and other minor fixes), formatted according to conventions, so that other people (and not just you) can read and do not frown every time: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program project1; uses  Windows; var  HWndMain, HWndPopup: HWND; const  CHotKeyShowId = 113000; function MainProc(Wnd: HWND; Msg: UINT; WParam: WPARAM; LParam: LPARAM): LRESULT; stdcall;begin  if (Msg = WM_HOTKEY) and (WParam = CHotKeyShowId) then  begin    ShowWindow(HWndMain, SW_SHOW);    ShowWindow(HWndPopup, SW_SHOW);//    SetForegroundWindow(HWndMain);    SetForegroundWindow(HWndPopup);  end;  case Msg of    WM_CLOSE:      UnregisterHotKey(HWndMain, CHotKeyShowId);    WM_DESTROY:      begin        PostQuitMessage(0);      Exit;      end;    WM_KEYDOWN:      if VK_ESCAPE = WParam then    begin        ShowWindow(HWndMain, SW_HIDE);        ShowWindow(HWndPopup, SW_HIDE);      end;    WM_LBUTTONDOWN:      MessageBox(HWndMain, PChar('Left Mouse Button'), PChar('MyProgram'), MB_OK);  end;  Result := DefWindowProc(Wnd, Msg, WParam, LParam);end; var  WndClass: TWndClass;  Msg: TMSG;  HWndForHideMainFromTaskBar: HWND;begin  WndClass.lpszClassName := 'MyWND';  WndClass.lpfnWndProc := @MainProc;  WndClass.hInstance := hInstance;  WndClass.hbrBackground := COLOR_WINDOW;  RegisterClass(WndClass);  HWndForHideMainFromTaskBar := CreateWindow(WndClass.lpszClassName, '', WS_POPUP,    0, 0, 0, 0, 0, 0, hInstance, nil);  HWndMain := CreateWindow(WndClass.lpszClassName, 'My API Window',    WS_OVERLAPPEDWINDOW or WS_VISIBLE, 500, 500, 500, 300, HWndForHideMainFromTaskBar,    0, hInstance, nil);  HWndPopup := CreateWindow(WndClass.lpszClassName, 'My Second Window',    WS_VISIBLE, 200, 500, 500, 300, HWndMain, 0, hInstance, nil);  if not RegisterHotKey(HWndMain, CHotKeyShowId, MOD_CONTROL, VK_BACK) then    MessageBox(HWndMain, PChar('HotKey Failed'), PChar('MyProgram'), 0);  while GetMessage(@Msg, 0, 0, 0) do  begin    TranslateMessage(Msg);  DispatchMessage(Msg);  end;end. ---------------------------------------------------------------------- RAW · 2017-10-21 21:41 QuoteThis is your example, only the types have been changed to compile under Win64 (and other minor fixes), formatted according to conventions,  ... Nice, thanks, yes right now I'm using an x86-computer and this is only a small test... I need to think about the visual appearance of the program and if I want to use ULW-API or GR32 LIB or GDI+ (..never saw a good looking GDI+ text example so far (like photoshop)... I need something that fits to a photo, so I think transparent text is the best I can do... let's see...). I would do it at least like this... this way it's easier to see what's going on, especially during a fast scroll...  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i begin  WndClass.lpszClassName:= 'MyWND';  WndClass.lpfnWndProc  := @MainProc;  WndClass.hInstance    := hInstance;  WndClass.hbrBackground:= COLOR_WINDOW;   RegisterClass(WndClass);   HWndForHideMainFromTaskBar:= CreateWindow  (WndClass.lpszClassName, '', WS_POPUP,   0, 0, 0, 0, 0, 0, hInstance, nil);   HWndMain:= CreateWindow  (WndClass.lpszClassName, 'My API Window',   WS_OVERLAPPEDWINDOW or WS_VISIBLE, 500, 500, 500, 300,   HWndForHideMainFromTaskBar, 0, hInstance, nil);   HWndPopup:= CreateWindow  (WndClass.lpszClassName, 'My Second Window',   WS_VISIBLE, 200, 500, 500, 300, HWndMain, 0, hInstance, nil);   if not RegisterHotKey(HWndMain, CHotKeyShowId, MOD_CONTROL, VK_BACK) then    MessageBox(HWndMain, PChar('HotKey Failed'), PChar('MyProgram'), 0);   while GetMessage(@Msg, 0, 0, 0) do  begin  TranslateMessage(Msg);    DispatchMessage(Msg);  end;end. btw: I really like the "THEN" and/or the "DO" at the left side, especially if there is a lot of code....... It's not really necessary but just a habit and I don't think my code is hard to read. I saw people writing left-justified code all over the place... everything ranged left... funny... And are these little differences really a problem? Version 1: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if not RegisterHotKey(HWndMain, CHotKeyShowId, MOD_CONTROL, VK_BACK) then    MessageBox(HWndMain, PChar('HotKey Failed'), PChar('MyProgram'), 0);  while GetMessage(@Msg, 0, 0, 0) do  begin    TranslateMessage(Msg);  DispatchMessage(Msg);  end;Version 2: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if not RegisterHotKey(HWndMain, CHotKeyShowId, MOD_CONTROL, VK_BACK)  then MessageBox(HWndMain, PChar('HotKey Failed'), PChar('MyProgram'), 0);   while GetMessage(@Msg, 0, 0, 0)  do   begin    TranslateMessage(Msg);    DispatchMessage(Msg);   end; Version 2 is definitely easier to read ... ---------------------------------------------------------------------- ASerge · 2017-10-22 09:00 Quote from: RAW on October 21, 2017, 11:41:44 pmVersion 2 is definitely easier to read ...  For me, it's terribly uncomfortable. Generally everyone has his own opinion, but then everyone agrees on one style. Then everyone follows this rule and everything becomes easier. And when someone says that all this is nonsense, but his version is more beautiful, then the rest can only wish that he showed his code less. ---------------------------------------------------------------------- RAW · 2017-10-22 16:59 QuoteGenerally everyone has his own opinion, but then everyone agrees on one style. Then everyone follows this rule and everything becomes easier. And when someone says that all this is nonsense, but his version is more beautiful, then the rest can only wish that he showed his code less. I know exactly what you mean, I see this all around me and saw it very intense in school: Dress like everyone else or get beaten up, talk like everyone else or get beaten up, do things like everyone else or get beaten up. Fortunately that was a very long time ago and I'm already outside this slavery-circle. Of course I understand that a team of programmers following the same rules is a good idea, but that doesn't mean every line needs to be identical... If you do what you like and I do what I like then everything is perfect I guess, so let's keep it this way.  Thanks again... ---------------------------------------------------------------------- metis · 2018-01-08 14:49 @RAW The easiest Way to hide the TaskbarButton, that I found is this: Code: [Select]uses   Windows, InterfaceBase, Win32Int, ... ... var   AppHnd : THandle;   EXStyle: Long; ...   AppHnd  := TWin32WidgetSet(WidgetSet).AppHandle; // <- Replace this by Your Handle   EXStyle := GetWindowLongA(AppHnd, GWL_EXSTYLE);   SetWindowLongA(AppHnd, GWL_EXSTYLE, EXStyle or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW); Though this is for LCL under Win32 (it works perfectly on my WinXP 32bit), at least the Windows-API-Functions and -Parameters should work in a WinConsole, too (didn't try it out). I know from some of Your former Posts, that You're familiar with these APIs, but: -> Why don't/can't You use them here ? BTW: Of course everybody may write his Code ad libitum, but if You want to share it with others, it's easier to follow common Conventions. ---------------------------------------------------------------------- Thaddy · 2018-01-08 15:47 If the window has the dialog style it also doesn't show up. For a mainform try fsSplash since fsDialog is sadly missing.... In Lazarus. (BUG) ---------------------------------------------------------------------- Remy Lebeau · 2018-01-09 23:12 Quote from: RAW on October 20, 2017, 07:33:01 pmcan anybody give me a hint how to get rid of the taskbar button ? There is another option that noone has mentioned yet: ITaskbarList.DeleteTab() QuoteDeletes an item from the taskbar. Your app can delete its own Taskbar button (and re-add it, via ITaskbarList.AddTab()) without having to mess around with the window styles at all. ---------------------------------------------------------------------- RAW · 2018-01-10 01:22 Thanks to all for the information, it's always nice to know several options. It's the first time I hear something about this "ITaskbarList" interface... funny... but good to know... ---------------------------------------------------------------------- metis · 2018-01-15 12:25 @Thaddy QuoteIf the window has the dialog style it also doesn't show up. For a mainform try fsSplash ... I tried out Your suggestion: -> It doesn't work for me (WinXP SP3 32bit + Lazarus v1.6.4 + FPC v3.0.2): I tried 'fsSplash' in 'FormCreate' and in the Object Inspector, and... ...still have a TaskbarButton. If I put 'FormStyle := fsSplash;' into 'FormShow', the App crashes with ErrMsg 'External: SIGSEGV'. Quotesince fsDialog is sadly missingThere is no 'FormStyle := fsDialog', but there is a 'BorderStyle := bsDialog'. Unfortunately, this doesn't hide the TaskbarButton either. -> 'Application.MainFormOnTaskbar := False;' or 'ShowInTaskBar := stNever' do not work      (= another Lazarus-Bug).      The same Problem occurs, it You want to make a Form transparent. => Solution: The Use of WindowsAPI-Calls. As an Example, how to solve these Lazarus-intrinsic Headaches, have a Look at 'Mouse Eyes'. 'Mouse Eyes' is a MouseTracker/MouseCursor-Follower. A little, but very useful Pascal-App, specially if You work with several Screens. I found it (many, many) Years ago at , and I use it until today. 'Mouse Eyes' has a MainForm, that is: - transparent, and - on Top (TOP or TOPMOST), and - without Border, without TitleBar, but - still movable and able to be closed with the Mouse.  You'll find the original D7-MouseEyes-Project, together with my Port to FPC/Lazarus in the Attachment: 'LazMouseEyesByMetis.7z'.