• Welcome to Jose's Read Only Forum 2023.
 

Nicola Question about TOPMOST WINDOW

Started by Zlatko Vid, December 05, 2020, 11:22:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Zlatko Vid

- because there is no interest in my friendly help i remove my answers

Nicola_Piano

Hi Zlatko,
I really appreciated your interest and your post. I treasured it. I couldn't answer earlier because I wasn't registered on this forum. I'm sorry you deleted the post.
Now I am and I want to express my thanks.
Nicola

Zlatko Vid

ahh...sorry i forget what is what
i hope that always_on_top window work for you

Nicola_Piano

#3
Hi Zlatko.
Yes, I was able to solve. Thanks to you anyway.  :)
Hello

Code (o2) Select

' prova topmost - Nicola P.
$ filename "Prova_Button.exe"
$ EscapeKeyEnd

  uses WinUtil


  MainWindow 271,118,WS_SYSMENU|WS_MINIMIZEBOX|WS_EX_TOPMOST


% HWND_TOPMOST= -1

% IDD_MAIN = 1000
% IDC_LBL1 = 1001         ' LABEL
% IDC_BTN1 = 1002
% IDC_BTN2 = 1003

global ac as int



function WndProc(sys hWnd, uMsg, wParam, lParam) as long callback
  ================================================================
  static sys style, Lbl1, hBtn1, hBtn2
  static string s
  static int bcolor=0xaabbee, blue=0x00FF0000
  RECT rcClient
   
  select umsg

case WM_CREATE

   style=WS_CHILD | WS_VISIBLE | ES_CENTER
   Lbl1=CreateWindowEx(0,"Static", "Hello", style, 0, 5, 264, 50, hWnd, IDC_LBL1, inst, null)

   'style=WS_CHILD | BS_TEXT | WS_VISIBLE| BS_OWNERDRAW
   style=WS_CHILD | BS_OWNERDRAW
   hBtn1=CreateWindowEx(0,"Button", "Start", style,8, 58, 79, 24, hWnd, IDC_BTN1, inst, null)
   hBtn2=CreateWindowEx(0,"Button", "Stop", style,178, 58, 79, 24, hWnd, IDC_BTN2, inst, null)

SetWindowText hWnd,"Nicola 12/2020"
SetWindowPos(hWnd,sys HWND_TOPMOST,1,1,271,118)
ShowWindow(hbtn1, SW_SHOW)
   ShowWindow(hbtn2, SW_SHOW) 
   

  case WM_CTLCOLORBTN

    sys hdc=wparam
    sys hwn=lparam
    RECT rec
    GetClientRect  hwn,@rec
    if hwn=hBtn1
      sys hbr=CreateSolidBrush bcolor
      FillRect hdc,@rec,hbr
      SetBkColor   hdc,bcolor
      SetTextColor hdc,0x90
      DrawText hDC,"Start",-1,@rec,0x25
      DeleteObject hbr
      return hbr
    endif
    if hwn=hBtn2
      sys hbr=CreateSolidBrush blue
      FillRect hdc,@rec,hbr
      SetBkColor   hdc,blue
      SetTextColor hdc,0x0
      DrawText hDC,"Stop",-1,@rec,0x25
      DeleteObject hbr
      return hbr
    endif


    case WM_COMMAND

        select loword(wParam)
                           
            case IDC_BTN1   'start
                if ac=0 then
                    ac=1
                 else
                    ac=0
                 end if
             
         end select

    case WM_CLOSE
DestroyWindow(hWnd)

    case WM_DESTROY
DestroyWindow(hWnd)
      PostQuitMessage 0


    case else
      return DefWindowProc(hWnd, uMsg, wParam, lParam)

    end select

end function