|
Das deutsche QBasic- und FreeBASIC-Forum Für euch erreichbar unter qb-forum.de, fb-forum.de und freebasic-forum.de!
|
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen |
Autor |
Nachricht |
oldirty
Anmeldungsdatum: 04.08.2005 Beiträge: 65
|
Verfasst am: 18.06.2006, 22:38 Titel: Titel-Leiste entfernen |
|
|
Mit dem folgenden Code ist das Bild matschig:
Code: |
option explicit
#include once "windows.bi"
screen 18
const title$="Test"
windowtitle title$
dim as any ptr HWnd
hwnd=findwindow(0,title$)
dim as long curstyle, newstyle, x
curstyle=GetWindowLong(hwnd, GWL_STYLE)
'curstyle=curstyle xor WS_MINIMIZEBOX 'Setzt Minimierembutton auf Inaktiv
'curstyle=curstyle xor WS_MAXIMIZEBOX 'Setzt Maximierembutton auf Inaktiv
'curstyle=curstyle xor WS_SYSMENU 'Entfernt alle Buttons
curstyle=curstyle xor WS_BORDER 'Entfernd Titelleiste, Bild "matschig"
newstyle=SetWindowLong(hwnd, GWL_STYLE, curstyle)
dim as integer posx, posy
dim xWindowInfo as WINDOWINFO
xWindowInfo.cbSize=sizeof(xWindowInfo)
GetWindowInfo(hwnd, @xWindowInfo)
With xWindowInfo.rcWindow
posx=.Left
posy=.Top
End With
SetWindowPos hwnd, 0, posx, posy, 0, 0, SWP_SHOWWINDOW or _ 'Zeigt window
SWP_NOSIZE or _ 'Behält Größe bei
SWP_NOACTIVATE or _ 'Fenster nicht aktiv
SWP_DRAWFRAME or _ 'Zeichnet Rahmen
SWP_FRAMECHANGED '<---Notwendig
for x=1 to 10
print "Testing window without a titlebar"
next x
sleep
|
Gibt es einen besseren Weg, die Titelleiste zu entfernen oder zumindest nachträglich (da ja mit Screen alle Daten schon feststehen) zu ändern?
Danke schon mal im Voraus
[EDIT]
Durch das Entfernen der Titelleiste ist der Clientrange (WindowInfo.rcClient) größer geworden, daher Wird das Fenster gestrechet.
Test:
Code: |
option explicit
#include once "windows.bi"
#define cstr str
screen 18
const title$="Test"
windowtitle title$
dim as any ptr HWnd
hwnd=findwindow(0,title$)
dim as integer posx, posy
dim xWindowInfo as WINDOWINFO
xWindowInfo.cbSize=sizeof(xWindowInfo)
GetWindowInfo(hwnd, @xWindowInfo)
Print "rcClient vorher:"
With xWindowInfo.rcClient
Print " (" & CStr(.Left) & "," & CStr(.Top) & ")-(" & CStr(.Right) & "," & CStr(.Bottom) & ")"
End With
dim as long curstyle, newstyle, x
curstyle=GetWindowLong(hwnd, GWL_STYLE)
'curstyle=curstyle xor WS_MINIMIZEBOX 'Setzt Minimierembutton auf Inaktiv
'curstyle=curstyle xor WS_MAXIMIZEBOX 'Setzt Maximierembutton auf Inaktiv
'curstyle=curstyle xor WS_SYSMENU 'Entfernt alle Buttons
curstyle=curstyle xor WS_BORDER 'Entfernd Titelleiste, Bild "matschig"
newstyle=SetWindowLong(hwnd, GWL_STYLE, curstyle)
GetWindowInfo(hwnd, @xWindowInfo)
Print "rcClient nachher:"
With xWindowInfo.rcClient
Print " (" & CStr(.Left) & "," & CStr(.Top) & ")-(" & CStr(.Right) & "," & CStr(.Bottom) & ")"
End With
xWindowInfo.cbSize=sizeof(xWindowInfo)
GetWindowInfo(hwnd, @xWindowInfo)
print
print "rcWindow:"
With xWindowInfo.rcWindow
posx=.Left
posy=.Top
Print " (" & CStr(.Left) & "," & CStr(.Top) & ")-(" & CStr(.Right) & "," & CStr(.Bottom) & ")"
End With
SetWindowPos hwnd, 0, posx, posy, 0, 0, SWP_SHOWWINDOW or _ 'Zeigt window
SWP_NOSIZE or _ 'Behält Größe bei
SWP_NOACTIVATE or _ 'Fenster nicht aktiv
SWP_DRAWFRAME or _ 'Zeichnet Rahmen
SWP_FRAMECHANGED '<---Notwendig
for x=1 to 10
print "Testing window without a titlebar"
next x
Dim TitleInfo As TITLEBARINFO
'Initialize structure
TitleInfo.cbSize = sizeof(TitleInfo)
'Retrieve information about the tilte bar of this window
GetTitleBarInfo hwnd, @TitleInfo
'Show some of that information
Print "Title bar rectangle:"
With TitleInfo.rcTitleBar
Print " (" & CStr(.Left) & "," & CStr(.Top) & ")-(" & CStr(.Right) & "," & CStr(.Bottom) & ")"
End With
sleep
|
|
|
Nach oben |
|
|
Dominik
Anmeldungsdatum: 22.12.2004 Beiträge: 172
|
Verfasst am: 21.06.2006, 17:07 Titel: |
|
|
Um das stretchen zu verhindern, kannst du mit GetTitleBarInfo()
die größe der Titelleiste herausbekommen und nun die
Fenstergröße auf (Fenstergröße - Größe der Titelleiste) setzen. |
|
Nach oben |
|
|
oldirty
Anmeldungsdatum: 04.08.2005 Beiträge: 65
|
Verfasst am: 21.06.2006, 20:13 Titel: |
|
|
Hallo,
diese Idee hatte ich auch, nur leider kann ich diese nicht umsetzen, auf jeden fall ändert sich nichts an dem Bild.
Hier mal mein Code:
Code: |
option explicit
#include once "windows.bi"
#define cstr str
screen 18
const title$="Test"
windowtitle title$
dim as any ptr HWnd
hwnd=findwindow(0,title$)
dim as integer posx, posy, TitleBarHeigt, w, h
screeninfo w, h
dim xWindowInfo as WINDOWINFO
xWindowInfo.cbSize=sizeof(xWindowInfo)
GetWindowInfo(hwnd, @xWindowInfo)
Print "rcClient vorher:"
With xWindowInfo.rcClient
Print " (" & CStr(.Left) & "," & CStr(.Top) & ")-(" & CStr(.Right) & "," & CStr(.Bottom) & ")"
End With
Dim TitleInfo As TITLEBARINFO
'Initialize structure
TitleInfo.cbSize = sizeof(TitleInfo)
'Retrieve information about the tilte bar of this window
GetTitleBarInfo hwnd, @TitleInfo
'Show some of that information
Print "Title bar rectangle:"
With TitleInfo.rcTitleBar
'Print " (" & CStr(.Left) & "," & CStr(.Top) & ")-(" & CStr(.Right) & "," & CStr(.Bottom) & ")"
TitleBarHeigt=.Bottom - .Top 'Höhe der Titelleiste ermitteln
End With
print TitleBarHeigt
print w, h
dim as long curstyle, newstyle, x
curstyle=GetWindowLong(hwnd, GWL_STYLE)
'curstyle=curstyle xor WS_MINIMIZEBOX 'Setzt Minimierembutton auf Inaktiv
'curstyle=curstyle xor WS_MAXIMIZEBOX 'Setzt Maximierembutton auf Inaktiv
'curstyle=curstyle xor WS_SYSMENU 'Entfernt alle Buttons
curstyle=curstyle xor WS_BORDER 'Entfernd Titelleiste, Bild "matschig"
newstyle=SetWindowLong(hwnd, GWL_STYLE, curstyle)
GetWindowInfo(hwnd, @xWindowInfo)
'print
'print "rcWindow:"
With xWindowInfo.rcWindow
posx=.Left
posy=.Top
' Print " (" & CStr(.Left) & "," & CStr(.Top) & ")-(" & CStr(.Right) & "," & CStr(.Bottom) & ")"
End With
SetWindowPos hwnd, 0, posx, posy, w, h-TitleBarHeigt, SWP_SHOWWINDOW or _ 'Zeigt window
SWP_NOACTIVATE or _ 'Fenster nicht aktiv
SWP_DRAWFRAME or _ 'Zeichnet Rahmen
SWP_FRAMECHANGED '<---Notwendig
Print "rcClient nachher:"
With xWindowInfo.rcClient
Print " (" & CStr(.Left) & "," & CStr(.Top) & ")-(" & CStr(.Right) & "," & CStr(.Bottom) & ")"
End With
xWindowInfo.cbSize=sizeof(xWindowInfo)
GetWindowInfo(hwnd, @xWindowInfo)
for x=1 to 10
print "Testing window without a titlebar"
next x
' Dim TitleInfo As TITLEBARINFO
'Initialize structure
TitleInfo.cbSize = sizeof(TitleInfo)
'Retrieve information about the tilte bar of this window
GetTitleBarInfo hwnd, @TitleInfo
'Show some of that information
Print "Title bar rectangle:"
With TitleInfo.rcTitleBar
Print " (" & CStr(.Left) & "," & CStr(.Top) & ")-(" & CStr(.Right) & "," & CStr(.Bottom) & ")"
End With
sleep
|
Kannst Du mir vielleicht ein Beispiel zeigen? |
|
Nach oben |
|
|
Dominik
Anmeldungsdatum: 22.12.2004 Beiträge: 172
|
Verfasst am: 22.06.2006, 16:34 Titel: |
|
|
Hi,
ich glaube mittlerweile zu wissen, warum es nicht geht und sehe auch keine Lösung, außer das ändern des Screen-Befehls von den FreeBASIC-Entwicklern.
Da der FB-Screen DirectX, sofern es vorhanden ist, zum Zeichnen und Erstellen des Grafikfensters benutzt und man bei DirectX die größe des Grafikfensters nachträglich ändern müsste, um das automatische stretchen zu verhindern, gibt es meiner Meinung nach keine Lösung die Titelleiste zu löschen ohne das der Screen gestrecht wird.
Leider |
|
Nach oben |
|
|
volta
Anmeldungsdatum: 04.05.2005 Beiträge: 1875 Wohnort: D59192
|
Verfasst am: 23.06.2006, 20:32 Titel: |
|
|
Hi,
ich hab 2 Lösungen gefunden (nur auf ME getestet), die aber beide auch nicht ganz befriedigend sind.
Code: | Option Explicit
#include once "windows.bi"
' Some defines and typedefs for the Win32Driver structure
#define WINDOW_TITLE_SIZE 128
#define WINDOW_CLASS_PREFIX "fbgfxclass_"
' Structure containing GfxLib's internal Windows info
Type WIN32DRIVER
Version As Integer
hInstance As HINSTANCE
WndClass As WNDCLASS
Wnd As HWND
Palette(0 To 255) As PaletteEntry
Blitter As Sub(Byval As Ubyte Ptr, Byval As Integer)
Is_Running As Integer
Is_Palette_Changed As Integer
Is_Active As Integer
w As Integer
h As Integer
Depth As Integer
FullScreen As Integer
Refresh_Rate As Integer
Window_Title As Ubyte Ptr
WindowClass(0 To WINDOW_TITLE_SIZE + Len(WINDOW_CLASS_PREFIX)-1) As Ubyte
Init As Function() As Integer
Exit As Function() As Integer
Paint As Function() As Integer
Thread As Sub(Byval Running_Event As HANDLE)
End Type
Extern FB_Win32 Alias "fb_win32" As WIN32DRIVER
Screen 18
Const title$="Testing window without a titlebar"
Windowtitle title$
'sleep
Dim As Uinteger curstyle, newstyle
curstyle = GetWindowLong(FB_Win32.Wnd, GWL_STYLE)
'-----------1.Version
newstyle = SetWindowLong(FB_Win32.Wnd, GWL_STYLE, curstyle And Not WS_BORDER )
SetWindowPos FB_Win32.Wnd, 0,0,0, FB_Win32.w +6, FB_Win32.h +6, SWP_NOMOVE
'----------
?FB_Win32.w,FB_Win32.h
Dim i As Integer
For i=1 To 10
Print title$
Next i
Sleep | Hier hab ich durch 'FB_Win32.w +6, FB_Win32.h +6,' das stretchen kompensiert. Diese Wert enspricht der Borderbreite (3) an allen Seiten, sollte sich irgendwo bei den System_metrics abfragen lassen.
Code: | '-----------2.Version
newstyle = SetWindowLong(FB_Win32.Wnd, GWL_STYLE, curstyle and not WS_CAPTION)
SetWindowPos FB_Win32.Wnd, 0,0,0, FB_Win32.w, FB_Win32.h, SWP_NOMOVE
'----------- | Dies hat keine Titelzeile,keinen Rand, nichts
Gruß Volta _________________ Warnung an Choleriker:
Dieser Beitrag kann Spuren von Ironie & Sarkasmus enthalten.
Zu Risiken & Nebenwirkungen fragen Sie Ihren Therapeuten oder Psychiater. |
|
Nach oben |
|
|
oldirty
Anmeldungsdatum: 04.08.2005 Beiträge: 65
|
Verfasst am: 24.06.2006, 11:54 Titel: |
|
|
Danke, auf Windows XP läuft es.
Das mit der kompensierung des streching habe ich auch so versucht. Leider mit der falschen Zahl (22 = Höhe der Titelleiste bei mir).
Danke. Das mit den Systemmetrics werde ich mal austesten.
[EDIT]
Hier ein Beispielprogramm in Form einer Sub:
Code: |
option explicit
#include once "windows.bi"
'Beispiel:
'Titlebar(hwnd,ToggleMinB) 'Wechselt den Status des MinButtons
'Titlebar(hwnd,ToggleMaxB) 'Wechselt den Status des MaxButtons
'Titlebar(hwnd,ToggleMinMaxB) 'Wechselt den Status beider Buttons
'Titlebar(hwnd,ToggleAlleB) 'Wechselt den Status ALLER (auch Close)Buttons
'Titlebar(hwnd,ToggleTitleB)'Wechselt den Status der Titelleiste
const ToggleMinB =1
const ToggleMaxB =2
const ToggleMinMaxB=ToggleMinB + ToggleMaxB
const ToggleAlleB =4
const ToggleTitleB =8
const ToggleWindowAlpha = 16
dim shared as integer Titelbarvisible, TitleBarHeight, BorderBreite, BorderHoehe
declare sub Titlebar (hwnd as any ptr, style as integer, alpha as integer = 255)
sub Titlebar (hwnd as any ptr, style as integer, alpha as integer = 255)
dim as long curstyle, newstyle
dim as integer WindowW, WindowH
curstyle=GetWindowLong(hwnd, GWL_STYLE)
Dim WinInfo As Long
WinInfo = GetWindowLong(hWnd, GWL_EXSTYLE)
screeninfo WindowW, WindowH
select case style
case 1
curstyle=curstyle xor WS_MINIMIZEBOX 'Setzt Minimierembutton auf Inaktiv
case 2
curstyle=curstyle xor WS_MAXIMIZEBOX 'Setzt Maximierembutton auf Inaktiv
case 3
curstyle=curstyle xor WS_MINIMIZEBOX 'Setzt Minimierembutton auf Inaktiv
curstyle=curstyle xor WS_MAXIMIZEBOX 'Setzt Maximierembutton auf Inaktiv
case 4
curstyle=curstyle xor WS_SYSMENU 'Entfernt alle Buttons
case 8
curstyle=curstyle xor WS_BORDER
if Titelbarvisible=0 then
BorderBreite= GetSystemMetrics(SM_CXFIXEDFRAME)*2
BorderHoehe=BorderBreite
WindowW+=BorderBreite
WindowH+=BorderHoehe
Dim TitleInfo As TITLEBARINFO
'Initialize structure
TitleInfo.cbSize = sizeof(TitleInfo)
'Retrieve information about the tilte bar of this window
GetTitleBarInfo Hwnd, @TitleInfo
'Show some of that information
With TitleInfo.rcTitleBar
TitleBarHeight=.Bottom - .Top 'Höhe der Titelleiste ermitteln
End With
Titelbarvisible=-1
else
WindowW+=BorderBreite
WindowH+=BorderHoehe+TitlebarHeight
Titelbarvisible=0
end if
case 16 'Geht noch nicht richtig.
' WinInfo = WinInfo Or WS_EX_LAYERED
' print bin(wininfo)
' SetWindowLong hWnd, GWL_EXSTYLE, WinInfo
' SetLayeredWindowAttributes hWnd, 0, alpha, LWA_ALPHA
end select
newstyle=SetWindowLong(hwnd, GWL_STYLE, curstyle)
dim as integer posx, posy
dim xWindowInfo as WINDOWINFO
xWindowInfo.cbSize=sizeof(xWindowInfo)
GetWindowInfo(hwnd, @xWindowInfo)
With xWindowInfo.rcWindow
posx=.Left
posy=.Top
End With
select case style
case 1 to 7
SetWindowPos hwnd, 0, posx, posy, 0, 0, SWP_SHOWWINDOW or _ 'Zeigt window
SWP_NOSIZE or _ 'Behält Größe bei
SWP_FRAMECHANGED '<---Notwendig
case 8
SetWindowPos hwnd, 0, posx, posy, WindowW, WindowH, SWP_SHOWWINDOW or _
SWP_FRAMECHANGED '<---Notwendig
end select
end sub
'#include once "konstanten.bi"
const prgname$="Testwindow"
screen 18
windowtitle prgname$
dim as any ptr hwnd
hwnd=findwindow(0, prgname$)
dim as integer x
for x = 1 to 10
print "Testdjflkasjjfjdfjdlkfjlksdjfsldkjf"
next x
sleep 500
Titlebar(hwnd,ToggleTitleB)
sleep 500
Titlebar(hwnd,ToggleTitleB)
Sleep 500
Titlebar(hwnd,ToggleMinMaxB)
Sleep 500
Titlebar(hwnd,ToggleMinMaxB)
Sleep 500
Titlebar(hwnd,ToggleMinB)
Sleep 500
Titlebar(hwnd,ToggleMinB)
Sleep 500
Titlebar(hwnd,ToggleMaxB)
Sleep 500
Titlebar(hwnd,ToggleMaxB)
sleep
|
|
|
Nach oben |
|
|
oldirty
Anmeldungsdatum: 04.08.2005 Beiträge: 65
|
Verfasst am: 07.08.2006, 20:25 Titel: |
|
|
Hinzufügen von Alpha-Wert (Transparenz des Fensters)
Code: |
option explicit
SETENVIRON("fbgfx=gdi") 'Damit der Transparent-Effekt auch geht.
'VOR dem ersten Screen-Aufruf setzen!!!
'Transparenz geht nich mit Standart-Screen
'da dieser mit directX erzeugt wird.
'http://www.freebasic.net/forum/viewtopic.php?t=5301
#include once "windows.bi"
'Beispiel:
'Titlebar(hwnd,ToggleMinB) 'Wechselt den Status des MinButtons
'Titlebar(hwnd,ToggleMaxB) 'Wechselt den Status des MaxButtons
'Titlebar(hwnd,ToggleMinMaxB) 'Wechselt den Status beider Buttons
'Titlebar(hwnd,ToggleAlleB) 'Wechselt den Status ALLER (auch Close)Buttons
'Titlebar(hwnd,ToggleTitleB) 'Wechselt den Status der Titelleiste
'Titlebar(hwnd,ToggleWindowAlpha,50) 'Setzt Window-Transparenz auf Wert xxx %
const ToggleMinB =1
const ToggleMaxB =2
const ToggleMinMaxB=ToggleMinB + ToggleMaxB
const ToggleAlleB =4
const ToggleTitleB =8
const ToggleWindowAlpha = 16
dim shared as integer Titelbarvisible, TitleBarHeight, _
BorderBreite, BorderHoehe, Alphaset
declare sub Titlebar (hwnd as any ptr, style as integer, alpha as integer = 0)
sub Titlebar (hwnd as any ptr, style as integer, alpha as integer = 0)
dim as long curstyle, newstyle
dim as integer WindowW, WindowH
curstyle=GetWindowLong(hwnd, GWL_STYLE)
Dim WinInfo As Long
WinInfo = GetWindowLong(hWnd, GWL_EXSTYLE)
screeninfo WindowW, WindowH
select case style
case 1
curstyle=curstyle xor WS_MINIMIZEBOX 'Setzt Minimierembutton auf Inaktiv
case 2
curstyle=curstyle xor WS_MAXIMIZEBOX 'Setzt Maximierembutton auf Inaktiv
case 3
curstyle=curstyle xor WS_MINIMIZEBOX 'Setzt Minimierembutton auf Inaktiv
curstyle=curstyle xor WS_MAXIMIZEBOX 'Setzt Maximierembutton auf Inaktiv
case 4
curstyle=curstyle xor WS_SYSMENU 'Entfernt alle Buttons
case 8
curstyle=curstyle xor WS_BORDER
if Titelbarvisible=0 then
BorderBreite= GetSystemMetrics(SM_CXFIXEDFRAME)*2
BorderHoehe=BorderBreite
WindowW+=BorderBreite
WindowH+=BorderHoehe
Dim TitleInfo As TITLEBARINFO
'Initialize structure
TitleInfo.cbSize = sizeof(TitleInfo)
'Retrieve information about the tilte bar of this window
GetTitleBarInfo Hwnd, @TitleInfo
'Show some of that information
With TitleInfo.rcTitleBar
TitleBarHeight=.Bottom - .Top 'Höhe der Titelleiste ermitteln
End With
Titelbarvisible=-1
else
WindowW+=BorderBreite
WindowH+=BorderHoehe+TitlebarHeight
Titelbarvisible=0
end if
case 16
dim alphap as integer
if alpha > 100 then alpha=100
if alpha < 0 then alpha= 0
alphap=255-(255*alpha/100)
if alphaset<>-1 then 'FensterSystem nur beim ersten Aufruf ändern
WinInfo = WinInfo xor WS_EX_LAYERED
SetWindowLong hWnd, GWL_EXSTYLE, WinInfo
end if
SetLayeredWindowAttributes hWnd, 0, alphap, LWA_ALPHA
alphaset=-1 'Ab jetzt steht FensterSystem für Alpha fest
end select
dim as integer posx, posy
dim xWindowInfo as WINDOWINFO
xWindowInfo.cbSize=sizeof(xWindowInfo)
GetWindowInfo(hwnd, @xWindowInfo)
With xWindowInfo.rcWindow
posx=.Left
posy=.Top
End With
select case style 'Aufrufen, damit Fenster neuen Modus auch anzeigt
'(Nur für 1 bis 8 notwendig, Alpha wird umgehend
'angewendet)
case 1 to 7
newstyle=SetWindowLong(hwnd, GWL_STYLE, curstyle)
SetWindowPos hwnd, 0, posx, posy, 0, 0, SWP_SHOWWINDOW or _ 'Zeigt window
SWP_NOSIZE or _ 'Behält Größe bei
SWP_FRAMECHANGED '<---Notwendig
case 8
newstyle=SetWindowLong(hwnd, GWL_STYLE, curstyle)
SetWindowPos hwnd, 0, posx, posy, WindowW, WindowH, SWP_SHOWWINDOW or _
SWP_FRAMECHANGED '<---Notwendig
end select
end sub
Const prgname$="Testwindow"
Screen 18
windowtitle prgname$
Dim As Any Ptr hwnd
hwnd=findwindow(0, prgname$)
Dim As Integer x
For x = 1 To 10
Print "Testdjflkasjjfjdfjdlkfjlksdjfsldkjf"
Next x
Sleep 500
Titlebar(hwnd,ToggleTitleB)
Sleep 500
Titlebar(hwnd,ToggleTitleB)
Sleep 500
Titlebar(hwnd,ToggleMinMaxB)
Sleep 500
Titlebar(hwnd,ToggleMinMaxB)
Sleep 500
Titlebar(hwnd,ToggleMinB)
Sleep 500
Titlebar(hwnd,ToggleMinB)
Sleep 500
Titlebar(hwnd,ToggleMaxB)
Sleep 500
Titlebar(hwnd,ToggleMaxB)
Sleep 500
Titlebar(hwnd,ToggleWindowAlpha,50)
sleep
|
|
|
Nach oben |
|
|
|
|
Du kannst keine Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum nicht antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen.
|
|