Page 1 of 1

Window without icon on titlebar, only the (X) button

Posted: Fri Aug 04, 2006 1:44 pm
by klaver
How create such window? it's very often used in C++ apps as a child window - in configuration, edit profile etc. etc.
Example:
http://www.realdn.net/msblog/content/bi ... roject.jpg

I want to have a normal window without minimize, maximize. Only the close (X) button. But if I use WS_SYSMENU, I have the stupid 16x16 icon with the system menu of the window.

Any ideas? Maybe someone already done sth like this ?

Posted: Fri Aug 04, 2006 2:45 pm
by srod
You could create a window with a #WS_EX_TOOLWINDOW extended style, but this reduces the font in the title bar.

E.g.

Code: Select all

OpenWindow(0, 0, 0, 219, 85, "TEST",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) 
SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_TOOLWINDOW)
ResizeWindow(0,#PB_Ignore,#PB_Ignore,220,100) : ShowWindow_(WindowID(0),#SW_SHOW)

Repeat 
  ev= WaitWindowEvent() 
Until ev=#PB_Event_CloseWindow 
However, I think that the example you've given is using a proper modal dialogue instead of a window.
The following example is taken from PureArea.net

Code: Select all

; English forum: http://purebasic.myforums.net/viewtopic.php?t=6060&highlight=
; Author: Spangly
; Date: 04. May 2003

; Proper Dialogs in Purebasic 
; Hacked together by Spangly 

Structure DLG_TEMPLATE 
    style.l 
    dwExtendedStyle.l 
    cdit.w 
    x.w 
    y.w 
    cx.w 
    cy.w 
    menu.w 
    class.w 
    title.l 
EndStructure 

dlg.DLG_TEMPLATE 
dlg\style=#WS_POPUP | #WS_BORDER | #WS_SYSMENU | #DS_MODALFRAME | #WS_CAPTION | #DS_CENTER 
dlg\cx=200 
dlg\cy=100 

Procedure DlgProc(hWnd, uMsg, wParam, lParam) 
    Select uMsg 
    Case #WM_INITDIALOG 
        CreateGadgetList(hWnd) 
        ButtonGadget(0,20,20,100,22,"OK") 
        ButtonGadget(1,20,50,100,22,"Cancel") 
        ButtonGadget(2,20,80,100,22,"Quit") 
        SetWindowText_(hWnd,"Dialog Title") 
    Case #WM_COMMAND 
        EndDialog_(hWnd,wParam&$FFFF) 
    EndSelect 
    ProcedureReturn 0 
EndProcedure 

OpenWindow(0, 325, 185, 600, 330, "",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar) 
Debug DialogBoxIndirectParam_(0,dlg,WindowID(0),@DlgProc(),0) 

Repeat 
    event.l=WaitWindowEvent() 
    Select event 
        Case #PB_Event_Gadget 
            Debug EventGadget() 
    EndSelect 
Until event=#PB_Event_CloseWindow 

End 

; ExecutableFormat=Windows 
; EnableAsm 
; EnableXP 
; EOF 
; ExecutableFormat=Windows
; EOF

Posted: Fri Aug 04, 2006 4:22 pm
by MrMat
Here's another way:

Code: Select all

OpenWindow(0, 0, 0, 240, 100, "Modal frame", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_Invisible)
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_DLGMODALFRAME)
HideWindow(0, 0)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Posted: Fri Aug 04, 2006 8:55 pm
by klaver
@MrMat

Thanks a lot, this works great.

Posted: Sat Aug 05, 2006 11:07 am
by srod
Doh! :D