Oxygen Basic

Programming => Problems & Solutions => Topic started by: Aurel on October 18, 2015, 11:18:05 AM

Title: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 18, 2015, 11:18:05 AM
HI
MIke maybe...probably  :D
Is there a way to have statusbar control flicker-free when we resizing
main window?
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 18, 2015, 12:03:50 PM
Hi Aurel,

There's a universal rule for flicker-free drawing: "Do not allow anything to redraw itself twice".

The best approach will be to create your (main) window without the CS_HREDRAW+CS_VREDRAW class styles. Many common controls redraw themselves regardless of whether their parent window redraws itself on window resize.

For example, all statusbar control windows have a CS_VREDRAW style of their own, and they are also forced to repaint themselves when they are autoresized horizontally. So, if their parent windows have those extra CS_HREDRAW+CS_VREDRAW class styles, then the statusbars are always repainted twice, first, due to their own CS_VREDRAW style and horizontal autosizing, and second, due to their parent's CS_HREDRAW+CS_VREDRAW class styles, which inevitably causes flicker.

FBSL's main window ME and additional forms created with a call to FbslForm() have only one class style defined, CS_DBLCLKS, that allows the main message pipe to receive and process WM_L/R/MBUTTONDBLCLK messages.
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 18, 2015, 02:33:57 PM
Hi Mike

I already have just that :
Code: [Select]
wcx.style = CS_DBLCLKS '|CS_OWNDC so there is no CS_VREDRAW - CS_HREDRAW

another thing main window style is :

Code: [Select]
winstyle = WS_MINMAXSIZE or WS_CLIPCHILDREN
but still STATUSBAR flickering when is under resizing
...well i blame  function

Code: [Select]
MoveWindow ( status,0,(h-32),w,h,1)which is under message WM_SIZE
last parameter is 1 wich mean
ByVal bRepaint As Long - inside include file

And also one thing ...maybe ...just maybe is problem because i use
old :
Code: [Select]
Type WNDCLASS
 'cbSize        as long
 Style         as long
 lpfnwndproc   as long
 cbClsextra    as long
 cbWndExtra    as long
 hInstance     as long
 hIcon         as long
' hIconSm       AS long
 hCursor       as long
 hbrBackground as long
 lpszMenuName  as long
 lpszClassName as long
End Type

..and not this one:

Code: [Select]
Type WNDCLASSEX
 cbSize        as int
 Style         as int
 lpfnwndproc   as sys
 cbClsextra    as int
 cbWndExtra    as int
 hInstance     as sys
 hIcon         as sys
 hCursor       as sys
 hbrBackground as sys
 lpszMenuName  as sys
 lpszClassName as sys
 hIconSm       AS sys
End Type

what you mean about that ?
by the way statusbar created in EBasic or Cretive have non-flicker statusbar
probably beacause are created with MFC addition ..i am not sure
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 18, 2015, 02:57:00 PM
well i found something here :
http://winapi.foosyerdoos.org.uk/code/commoncntrls/htm/createstatusbar.php

and remove api func MoveWindow from WM_SIZE
and add this:

Code: [Select]
SendMessage status,WM_SIZE ,0,0like is in that example (in C).
and seems that statusbar not flickering  ;)

by the way this statusbar is part of my AScio2 editor written in Oxygen.
Next thing is flickering of Listbox...
i will look more into this problem...  ::)
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 18, 2015, 03:27:34 PM
1. WNDCLASS requires RegisterClass(), WNDCLASSEX requires RegisterClassEx(). Don't be lazy bones while typing your code; prefer to use WNDCLASSEX/RegisterClassEx/CreateWindowEx. WNDCLASSEX should be defined as shown above; do not change anything to long -- OxygenBasic is sensitive to proper use of sys in certain places.

2. MoveWindow() is not a proper way to handle statusbar resizing. This function generates a cascade of events that make the statusbar repaint itself several times causing flicker.

The statusbar is a self-resizing control. Just send it a WM_SIZE message with zero parameters and it will do everything itself: it will move itself to the bottom of its parent and it will automatically adjust its own height and width to fit.

Consider the following short FBSL script. It will provide you with a flicker-free statusbar. Note that MSCtls_StatusBar32 is a predefined class and you don't need to register it. Just use CreateWindowEx() to respawn it with zero X and Y, zero width and height, and zero window style and extended style. FbslControl() is intrinsically mapped to CreateWindowEx() as commented in the script.

The statusbar will appropriately resize and reposition itself automatically whenever it receives WM_SIZE from its parent. No exessive repainting will occur and flicker will go away.

Code: OxygenBasic
  1. ' CTLID=control ID, X=x pos; Y=y pos; W=width; H=height; S=window styles; XS=extended window styles as per CreateWindowEx()
  2. '                              CLASS NAME     PARENT CAPTION    CTLID X  Y  W  H  S  XS
  3. Dim hStatus = FbslControl("MSCtls_StatusBar32", ME, "Ready...", 1000, 0, 0, 0, 0, 0, 0)
  4. Center(ME): Show(ME)
  5.  
  6. Begin Events
  7.   Select Case CBMSG
  8.     Case &H5 ' WM_SIZE
  9.      SendMessage(hStatus, &H5, 0, 0)
  10.   End Select
  11. End Events


[EDIT] You were a tad faster than me to post. :)
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 18, 2015, 09:19:09 PM
Hi Mike
Thank you of course  :)

Do you can show example with LISTBOX without flickering?
In FBSL ...if is not problem?
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 19, 2015, 06:46:24 AM
Hi Aurel,

The following FBSL script (and of course its equivalent in OxygenBasic if its main window doesn't have CS_HREDRAW/CS_VREDRAW and has WS_CLIPCHILDREN) will provide you with a GUI that's perfectly flicker-free under XP Classic and in absolutely all modes under Vista and subsequent Windows operating systems' DWM. The only slight problem it may have is the listbox' currently highlited line under any XP theme. Unlike Vista+ DWM, the XP theme manager draws highlighted backgrounds directly on screen rather than in the backbuffer, so some faint flicker is unavoidable.

Code: OxygenBasic
  1. #Include <Include\Windows.inc>
  2.  
  3. #Define LST_STYLE WS_CHILD BOr WS_VISIBLE BOr WS_TABSTOP BOr LBS_NOINTEGRALHEIGHT
  4. #Define LST_EXTSTYLE WS_EX_CLIENTEDGE
  5.  
  6. Macro ListAddString(s) = SendMessage(hList, LB_ADDSTRING, 0, s)
  7. Macro ResizeStatusBar() = SendMessage(hStatus, WM_SIZE, 0, 0)
  8. Macro ResizeListBox() = MoveWindow(hList, 40, 40, LoWord(CBLPARAM) - 80, HiWord(CBLPARAM) - 100, TRUE)
  9.  
  10. Type RECT: Left As Long, Top As Long, Right As Long, Bottom As Long: End Type
  11.  
  12. Dim hList, hStatus, rc As RECT
  13.  
  14. Resize(ME, 0, 0, 500, 300) ' FBSL resizes based on non-client, rather than client, area dimensions, so ...
  15. GetClientRect(ME, @rc) ' ... get whatever client area the main window actually has into rc.Right/rc.Bottom
  16.  
  17. hList = FbslControl("ListBox", ME, "", 1000, 40, 40, rc.Right - 80, rc.Bottom - 100, LST_STYLE, LST_EXTSTYLE)
  18. hStatus = FbslControl("MSCtls_StatusBar32", ME, "Ready...", 1001, 0, 0, 0, 0, 0, 0)
  19.  
  20. ListAddString("Some")("listbox")("strings")("added")("for")("your")("enjoyment")
  21.  
  22. Center(ME): Show(ME)
  23.  
  24. Begin Events
  25.   Select Case CBMSG
  26.     Case WM_SIZE
  27.       ' NB: the order in which controls are
  28.      ' resized and/or moved by MoveWindow()
  29.      ' or SetWindowPos() may matter much!
  30.      ResizeListBox()
  31.       ResizeStatusBar()
  32.   End Select
  33. End Events

The general rule here is to first, resize/reposition all manually resizable controls, and then, allow auto-resizable controls such as statusbars, toolbars and/or rebars to do their job automatically.

It should however be noted that separate calls to MoveWindow() and/or SetWindowPos() for each manually resizable control isn't the best solution. It will not be noticeable with just a couple of controls on the form, but if the number of controls is a dozen or more, you will clearly see each control crawling to its new place like a cockroach one at a time, and especially on a slow PC.

MS Windows offers a method to eliminate that unwanted behavior and resize/reposition some or all of the manually resizable controls instantaneously in one single repaint of the main window. There are three matching Win32 APIs used for that purpose: BeginDeferWindowPos(), DeferWindowPos(), and EndDeferWindowPos().

-- BeginDeferWindowPos() accepts the number of child control windows you wish to resize/reposition instantaneously, and returns a sys hDwp handle that should be used in subsequent calls to the other APIs. Note that all child controls must belong to a common immediate parent. If at least one has some other parent, e.g. if it is located on another form, the entire method will silently fail and all the controls will remain in their original places.

-- DeferWindowPos() accepts the hDwp handle from a previous call to BeginDeferWindowPos() or DeferWindowPos() and has the other parameters exactly like those of SetWindowPos() function. DeferWindowPos() again returns a new hDwp handle that must be used in the next function call.

-- EndDeferWindowPos() accepts the last hDwp handle returned from the last DeferWindowPos() call and actually repositions instantaneously all the controls that have just been supplied with a corresponding DeferWindowPos() call.

Pseudocode might look as follows:

Code: OxygenBasic
  1. ' ........
  2. Case WM_SIZE
  3.   Dim hDwp = BeginDeferWindowPos(3) ' plan to resize/move 3 child controls
  4.  hDwp = DeferWindowPos(hDwp, hCtrl1, ...) ' prepare resize/move of control #1; other params as per SetWindowPos
  5.  hDwp = DeferWindowPos(hDwp, hCtrl2, ...) ' prepare resize/move of control #2
  6.  hDwp = DeferWindowPos(hDwp, hCtrl3, ...) ' prepare resize/move of control #3
  7.  EndDeferWindowPos(hDwp) ' actually move all 3 controls instantaneously
  8.  SendMessage(hStatus, WM_SIZE, 0, 0) ' let auto-resizable controls do their job
  9. ' ........
  10.  


Hope this helps. :)
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 19, 2015, 12:33:55 PM
Hi Mike
and thank you very much on reply  ;)
well i have some problems to find my version of FBSL editor written in Oxygen
but i quickly modify one for FB and work without trouble then i finally compile
your FBSL example .
..well status bar work fine ..i mean with almost no-flickering but lisbox flicker
same as mine 
i still dont try way with few api which you recommend me
but i will .

In attachment is source code of editor and listbox example
(hehe ..i even modify toolbar bitmaps..)

[attachment deleted by admin]
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 19, 2015, 04:53:02 PM
Thanks for the zip, Aurel!

I can't compile FBSL scripts with your editor (you can't compile them from the command line or shell; you must use the FBSL2EXE.fbs compiler script from the FBSL v3.5 RC2 distro properly installed on your PC) but I can load an FBSL script into it and I can also run its manually precompiled executable from the same directory where the script is.

Below is the zip with two videos of running Listbox.exe under XP Sp3 Classic and XP Sp3 Luna-themed. None of them show any signs of flicker except for very faint shimmering of the themed listbox' white "Some" (line 0 -- that's the default selection when the app starts) and then blue "strings" (line 2 selected with the mouse). The statusbar shows absolutely no flicker in either video. And I repeat, under Vista, 7, 8, 8.1 and 10 there will be no flicker at all in the unthemed Classic, or opaquely themed Basic, or semi-transparent Aeroglass modes of DWM operation.

You are probably still under your legacy XP Sp2. That's very bad and I told you about that more than once in the past. We do not know how bad your video drivers are and what broken spam you could have additionally installed over those years. Sp1 and Sp2 were very buggy, and Sp3 also enjoyed hundreds of updates and fixes during the years it was supported by MS. So what I (and everyone else except you) may be seeing on our XP screens may not be available to you by definition no matter how hard we try.

As the last resort, try to rewrite this Listbox.fbs script in OxygenBasic (this isn't too difficult), compile it, and if you still see it flicker, then send the exe to me to check it on my PC. If I see no flicker while you see one, then there will be no other cure to this problem than throw your PC away in the trash bin. :)

[attachment deleted by admin]
Title: Re: STATUSBAR - FLICKER FREE?
Post by: JRS on October 19, 2015, 05:05:46 PM
Quote
If I see no flicker while you see one, then there will be no other cure to this problem than throw your PC away in the trash bin.

That may have crossed the line with Aurel and you will join the rest of us being drug addicts hooked on a magical pipe Aurel keeps referring to.
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 21, 2015, 08:24:56 AM
Hi Mike
and tanks for video ..
something it is not normal...and please stop with stupid observations
that XP-SP2 is bad and that your XP-SP3 is fine ...this simply is not true.
Also i use this older PC for programming and other programs i use for many
daily things...and all those things work perfactly fine.
Sooo i try same program on my kid win7 computer which is 3 year old
and same stupid listbox flickering is present.
so i again compile similar program in EBasic (on old PC)and there is no any kind of flickering.
And yes i will do that again in Oxygen Basic using this time WINDOWCLASSEX...

PS...i don't want bothering you ...so forget
i will find solution   :)
Title: Re: STATUSBAR - FLICKER FREE?
Post by: JRS on October 21, 2015, 09:14:56 AM
Quote from: Aurel
something it is not normal...and please stop with stupid observations.


(http://www.hellblazer.com/media/foot.gif)
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 21, 2015, 09:10:31 PM
Hmmm Aurel,

Nobody, but nobody has ever called me "stupid". "Wild faker" yes, quite recently, "stupid" no, never, even my wives. :)

XP Sp3 isn't mine, it's every-bloody-body's standard out there while XP Sp2 is exclusively yours among all the BASIC'ers known to me on all currently existing BASIC sites. Have you seen my videos? Yes. Isn't that proof enough? No? Do you want me to re-write the code in OxygenBasic for you and compile it and film it on all of my four (!) PCs again and then send it to you for rejection? I could have but why should I?

Why should I jump out of my pants for the sake of a person who says "yes, your statusbar code doesn't flicker" and still sends me in the same message his editor script which keeps on using buggy MoveWindow() to reposition its own statusbar that's flickering like hell (read spitting) right in my face? Have you been able to compile my FBSL code, Aurel? Your editor can't compile it, so how did you manage to even check out my suggestions before criticizing them? Whom have I been telling all these things to, and what for?! Don't I have other things on my hands other than wasting my time giving pieces of advice and writing code and compiling demos and filming videos for a man that's deaf to my reasoning and blind to my demos and films?

After all, those problems are all yours, not mine.

My listbox and stausbar script you criticize is precompiled and attached in the zip below. The executable isn't password protected or exe-packed. You can decompile it freely to see if I'm cheating you regarding its code identity. Let's see if anybody at all in the whole world confirms your words that it flickers, and not mine that it doesn't, any more than was shown in my videos and commented on verbally in my messages.

After that you may go look for a solution youself. But it seems almost certain now that the best solution has already been suggested, whether you like it or not, by me in my previous post. :)

[attachment deleted by admin]
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 22, 2015, 04:38:42 AM
hmmm Mike
first of all ....i dont say that you are stupid... than that point that sp3 is better
and what a heck sp2 -or  sp3 have with flickering...NOTHING.
OK  :)
but who care...
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 22, 2015, 06:35:43 AM
Aurel,

If Sp3 doesn't flicker while Sp2 does, there's a bug in Sp2, not in the code we're running. If Sp2 has a bug while Sp3 hasn't, it means Sp2 is buggy and bad, and Sp3 is bugless and good. People usually throw out bad things and keep good things. That's my point expressed in very simple terms and basic English.

If you want to be a Sith and see things that aren't there, stick with Sp2. I prefer to stay a Dagobahn and stick with Sp3. Sorry but that makes our further communication in the field of control flicker totally pointless.  ::)
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Peter on October 22, 2015, 08:21:54 AM
Quote
If Sp2 has a bug while Sp3 hasn't, it means Sp2 is buggy and bad, and Sp3 is bugless and good.

Explanation for children. (Punch and Judy show)  ;D
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 22, 2015, 10:07:53 AM
Punch...  ;D ;D ;D

Hi mister Mike 

Quote
Have you been able to compile my FBSL code, Aurel? Your editor can't compile it, so how did you manage to even check out my suggestions before criticizing them?

yes of course..without problem i can run your .fbs script with my ASci_FBSL editor
so i see that listbox flickering ...there is no need to lie about that ..right?

As I suspect main problem connected with flickering is because i use
WNDCLASS and not WNDCLASSEX ...

****************************************************
So proper way for GUI application is to use WNDCLASSEX.
****************************************************
also as window style must be used this :
style   = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN

Here is test program with listbox control..so anyone can try to compile
and to see how work.
all best Aurel   :D


Code: [Select]
'skeleton VB way...
$ filename "skeleton.exe"
include "rtl32.inc"
'#lookahead
'structures
Type WNDCLASSEX
 cbSize        as int
 Style         as int
 lpfnwndproc   as sys
 cbClsextra    as int
 cbWndExtra    as int
 hInstance     as sys
 hIcon         as sys
 hCursor       as sys
 hbrBackground as sys
 lpszMenuName  as sys
 lpszClassName as sys
 hIconSm       AS sys
End Type

Type POINTAPI
 x as long
 y as long
End Type

Type MSG
 hwnd    as sys
 message as int
 wParam  as sys
 lParam  as sys
 time    as dword
 pt      as POINTAPI
End Type

Type RECT
 Left   as Long
 Top    as Long
 Right  as Long
 Bottom as Long
End Type



'constants
% IDI_WINLOGO     = 32517
% IDI_APPLICATION = 32512
% IDC_ARROW       = 32512
% CS_OWNDC        = 32
% CS_DBLCLKS      =  &H8
% SW_NORMAL       = 1
% SW_SHOW         = 5

% WM_CREATE      = 1
% WM_DESTROY     = 2
% WM_PAINT       = 15
% WM_QUIT        = 18
% WM_SIZE        = 5
% WM_MOVE        = 3
% WM_CHAR        = 258
% WM_KEYDOWN     = 256
% WM_KEYUP       = 257
% WM_MOUSEMOVE   = 512
% WM_MBUTTONDOWN = 519
% WM_LBUTTONDOWN = 513
% WM_RBUTTONDOWN = 516
% WM_LBUTTONUP   = 514
% WM_RBUTTONUP   = 517
% WM_MBUTTONUP   = 520

% WS_OVERLAPPEDWINDOW = 0x00CF0000
% WS_SYSMENU     = 0x80000
% WS_OVERLAPPED  = WS_SYSMENU     
% WS_POPUP       = 0x80000000
% WS_DLGFRAME    = 0x400000
% WS_VISIBLE     = 0x10000000

% WS_CLIPSIBLINGS = 0x4000000
% WS_CLIPCHILDREN = 0x2000000
'defines...
SYS WHITE_BRUSH = 0

'declarations...
Declare Function LoadIcon         Lib "user32.dll"   Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As Any) As Long
Declare Function LoadCursor       Lib "user32.dll"   Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As Long
Declare Function GetModuleHandle  Lib "kernel32.dll" Alias "GetModuleHandleA" (sys lpModuleName) as Long
Declare Function RegisterClassEx  Lib "user32.dll"   Alias "RegisterClassExA" (byref lpwcx as WNDCLASSEX) as Long
Declare Function CreateWindowEx   Lib "user32.dll"   Alias "CreateWindowExA" (byval dwExStyle AS INT,byval lpClassName AS STRING,byval lpWindowName AS STRING,byval dwStyle AS INT,byval x AS INT,byval y AS INT,byval nWidth AS INT,byval nHeight AS INT,byval hWndParent AS INT,byval hMenu AS INT,byval hInstance AS INT,byval lpParam AS INT) as Long
Declare Function TranslateMessage Lib "user32.dll"  (byref lpMsg as MSG) as Long
Declare Function DispatchMessage  Lib "user32.dll"   Alias "DispatchMessageA" (byref lpMsg as MSG) as Long
Declare Function GetMessage       Lib "user32.dll"   Alias "GetMessageA" (lpMsg As MSG, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Declare Function ShowWindow       Lib "user32.dll"  (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Declare Function UpdateWindow     Lib "user32.dll"  (ByVal lhwnd As Long) As Long
Declare Function MoveWindow       Lib "user32.dll" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Declare Function DefWindowProc    Lib "user32.dll"  Alias "DefWindowProcA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Sub PostQuitMessage       Lib "user32.dll"  (ByVal nExitCode As Long)
Declare Function GetClientRect  Lib "user32.dll" (ByVal hwnd As sys, ByRef lpRect As RECT) As Long

Declare Function GetStockObject Lib "gdi32.dll" (ByVal nIndex As Long) As Long

Declare Function CreatePopupMenu Lib "user32.dll" () As Long
Declare Function CreateMenu      Lib "user32.dll" () As Long
Declare Function GetMenu         Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function SetMenu         Lib "user32.dll" (ByVal hwnd As Long, ByVal hMenu As Long) As Long
Declare Function AppendMenu      Lib "user32.dll" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Declare Function DrawMenuBar     Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function DeleteMenu      Lib "user32.dll" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Declare Function DestroyMenu     Lib "user32.dll" (ByVal hMenu As Long) As Long
Declare Function TrackPopupMenu  Lib "user32.dll" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hwnd As Long, lprc As RECT) As Long
'
'GetClientSize / GetClientRect
Declare Function GetSize(int window , winX as int, winY as int, winW as int, winH as int)

Dim wcx as WNDCLASSEX
Dim wm as MSG
Dim hwnd,style, Wx, Wy, Ww, Wh, wparent as Long
Dim wcaption,ClassName as String
Dim rc as RECT
'wcaption  = "MyWindow"
classname = "Oxygen"
style   = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN
Wx=0 : Wy=0 : Ww=640 : Wh=480
wparent = 0 'HWND_DESKTOP
'listbox def -------------------------------
INT LBox,lbx=20,lby=20,lw=300,lh=200,LBID=100
'RECT def -----------------------
INT Lx,Ty,Hs,Vs

'FILL WNDCLASSEX structure :::::::::::::::::::::::::::::::
inst = GetModuleHandle 0
wcx.cbSize        = sizeOf(WNDCLASSEX)
wcx.style         = CS_DBLCLKS
wcx.lpfnWndProc   = &WndProc
wcx.cbClsExtra    = 0
wcx.cbWndExtra    = 0
wcx.hInstance     = inst
wcx.hIcon         = LoadIcon 0,IDI_APPLICATION         
wcx.hCursor       = LoadCursor 0,IDC_ARROW 
wcx.hbrBackground = GetStockObject(WHITE_BRUSH)     
wcx.lpszMenuName  = strptr ""
wcx.lpszClassName = strptr Classname
wcx.hIconSm       = 0

RegisterClassEx wcx
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

wcaption  = "MyWindowEx"
'create window -------------------------------
Hwnd = CreateWindowEx 0,ClassName , wcaption, style, Wx, Wy, Ww, Wh, wparent, 0, inst,0
ShowWindow Hwnd,SW_SHOW
'create listbox
LBox = CreateWindowEx 0x200,"LISTBOX","", 0x50000140, lbx, lby, lw, lh, Hwnd, 0,0,LBID

'message loop-----------------
WHILE GetMessage(wm,0,0,0)
     TranslateMessage wm
     DispatchMessage  wm
WEND

'main callback procedure ---------------------------------------
Function WndProc (sys hwnd,wMsg,wParam,lParam) as sys callback
Select wMsg

Case WM_SIZE
     GetSize(Hwnd , Lx, Ty, Hs, Vs)   
MoveWindow (LBox, lbx , lby, Hs-40, Vs-50, 1)

Case WM_DESTROY
PostQuitMessage 0

End Select
'never put default return inside select
Return DefWindowProc(Hwnd,wMsg,wParam,lParam)

End Function
'------------------------------------------

'GetClientsize --------------------------------------------------------------------------------
SUB GetSize(int window , winX as int, winY as int, winW as int, winH as int)
GetClientRect( window, rc)
'hndx=0:hndy=0:hndw=0:hndh=0
winX = rc.Left
winY = rc.top
winW = rc.right
winH = rc.bottom
'Return rc
End SUB
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 22, 2015, 12:31:39 PM
@Peter:

Quote
If Sp2 has a bug while Sp3 hasn't, it means Sp2 is buggy and bad, and Sp3 is bugless and good.
Explanation for children. (Punch and Judy show)  ;D

Exactly! I'm trying to help Aurel to understand English better because it is only now that he has succeeded in decrypting the very first sentence in the message I posted three days ago. :o He does not or he can not read and understand what I'm telling him! ;D


@Aurel:

The following FBSL script (and of course its equivalent in OxygenBasic if its main window doesn't have CS_HREDRAW/CS_VREDRAW and has WS_CLIPCHILDREN) will provide you with a GUI that's perfectly flicker-free ...

This was the first sentence in the message I posted to you three days ago. I am glad you have finally found the time to read it and translate successfully. I am also glad you implemented some of my suggestions in your OxygenBasic code. I also hope you will, from now on, be using SendMessage(hStatus, WM_SIZE, 0, 0) to reposition your statusbar both in your editor code and elsewhere.

I will however also strongly recommend using my BeginDeferWindowPos()/DeferWindowPos()/EndDeferWindowPos() suggestion whenever your GUI is going to host some five visible controls or more.

Good luck! :)
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 22, 2015, 02:53:28 PM
Aurel,

Your code contained bugs. Here's a full version that behaves for me exactly like FBSL: no flicker in both controls under Classic, slight flicker of blue selected line in the listbox under Luna.

Code: [Select]
'skeleton VB way...
$ filename "skeleton.exe"
'include "rtl32.inc"
'#lookahead
'structures
Type WNDCLASSEX
 cbSize        as int
 Style         as int
 lpfnwndproc   as sys
 cbClsextra    as int
 cbWndExtra    as int
 hInstance     as sys
 hIcon         as sys
 hCursor       as sys
 hbrBackground as sys
 lpszMenuName  as sys
 lpszClassName as sys
 hIconSm       AS sys
End Type

Type POINTAPI
 x as long
 y as long
End Type

Type MSG
 hwnd    as sys
 message as int
 wParam  as sys
 lParam  as sys
 time    as dword
 pt      as POINTAPI
End Type

Type RECT
 Left   as Long
 Top    as Long
 Right  as Long
 Bottom as Long
End Type



'constants
% IDI_WINLOGO     = 32517
% IDI_APPLICATION = 32512
% IDC_ARROW       = 32512
% CS_OWNDC        = 32
% CS_DBLCLKS      =  &H8
% SW_NORMAL       = 1
% SW_SHOW         = 5

% WM_CREATE      = 1
% WM_DESTROY     = 2
% WM_PAINT       = 15
% WM_QUIT        = 18
% WM_SIZE        = 5
% WM_MOVE        = 3
% WM_CHAR        = 258
% WM_KEYDOWN     = 256
% WM_KEYUP       = 257
% WM_MOUSEMOVE   = 512
% WM_MBUTTONDOWN = 519
% WM_LBUTTONDOWN = 513
% WM_RBUTTONDOWN = 516
% WM_LBUTTONUP   = 514
% WM_RBUTTONUP   = 517
% WM_MBUTTONUP   = 520

% WS_OVERLAPPEDWINDOW = 0x00CF0000
% WS_SYSMENU     = 0x80000
% WS_OVERLAPPED  = WS_SYSMENU     
% WS_POPUP       = 0x80000000
% WS_DLGFRAME    = 0x400000
% WS_CHILD       = 0x40000000
% WS_VISIBLE     = 0x10000000

% WS_CLIPSIBLINGS = 0x4000000
% WS_CLIPCHILDREN = 0x2000000

% WS_EX_CLIENTEDGE = 0x200
% LBS_NOINTEGRALHEIGHT = 0x100
% LBS_HASSTRINGS = 0x40
% LB_ADDSTRING   = 0x180

'defines...
SYS WHITE_BRUSH = 0

'declarations...
Declare Function LoadIcon         Lib "user32.dll"   Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As Any) As Long
Declare Function LoadCursor       Lib "user32.dll"   Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As Long
Declare Function GetModuleHandle  Lib "kernel32.dll" Alias "GetModuleHandleA" (sys lpModuleName) as Long
Declare Function RegisterClassEx  Lib "user32.dll"   Alias "RegisterClassExA" (byref lpwcx as WNDCLASSEX) as Long
Declare Function CreateWindowEx   Lib "user32.dll"   Alias "CreateWindowExA" (byval dwExStyle AS INT,byval lpClassName AS STRING,byval lpWindowName AS STRING,byval dwStyle AS INT,byval x AS INT,byval y AS INT,byval nWidth AS INT,byval nHeight AS INT,byval hWndParent AS INT,byval hMenu AS INT,byval hInstance AS INT,byval lpParam AS INT) as Long
Declare Function TranslateMessage Lib "user32.dll"  (byref lpMsg as MSG) as Long
Declare Function DispatchMessage  Lib "user32.dll"   Alias "DispatchMessageA" (byref lpMsg as MSG) as Long
Declare Function GetMessage       Lib "user32.dll"   Alias "GetMessageA" (lpMsg As MSG, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Declare Function ShowWindow       Lib "user32.dll"  (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Declare Function UpdateWindow     Lib "user32.dll"  (ByVal lhwnd As Long) As Long
Declare Function MoveWindow       Lib "user32.dll" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Declare Function DefWindowProc    Lib "user32.dll"  Alias "DefWindowProcA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Sub PostQuitMessage       Lib "user32.dll"  (ByVal nExitCode As Long)
Declare Function GetClientRect  Lib "user32.dll" (ByVal hwnd As sys, ByRef lpRect As RECT) As Long

Declare Function GetStockObject Lib "gdi32.dll" (ByVal nIndex As Long) As Long

Declare Function CreatePopupMenu Lib "user32.dll" () As Long
Declare Function CreateMenu      Lib "user32.dll" () As Long
Declare Function GetMenu         Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function SetMenu         Lib "user32.dll" (ByVal hwnd As Long, ByVal hMenu As Long) As Long
Declare Function AppendMenu      Lib "user32.dll" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Declare Function DrawMenuBar     Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function DeleteMenu      Lib "user32.dll" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Declare Function DestroyMenu     Lib "user32.dll" (ByVal hMenu As Long) As Long
Declare Function TrackPopupMenu  Lib "user32.dll" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hwnd As Long, lprc As RECT) As Long

Declare Function SendMessage     Lib "user32.dll" Alias "SendMessageA"

Dim wcx as WNDCLASSEX
Dim wm as MSG
Dim hwnd,style, Wx, Wy, Ww, Wh, wparent as Long
Dim wcaption,ClassName as String
Dim rc as RECT
'wcaption  = "MyWindow"
classname = "Oxygen"
style   = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN
Wx=0 : Wy=0 : Ww=640 : Wh=480
wparent = 0 'HWND_DESKTOP
'listbox def -------------------------------
INT LBox, lbx=20,lby=20,lw=300,lh=200,LBID=100

'FILL WNDCLASSEX structure :::::::::::::::::::::::::::::::
inst = GetModuleHandle 0
wcx.cbSize        = sizeOf(WNDCLASSEX)
wcx.style         = CS_DBLCLKS
wcx.lpfnWndProc   = &WndProc
wcx.cbClsExtra    = 0
wcx.cbWndExtra    = 0
wcx.hInstance     = inst
wcx.hIcon         = LoadIcon 0,IDI_APPLICATION         
wcx.hCursor       = LoadCursor 0,IDC_ARROW
wcx.hbrBackground = GetStockObject(WHITE_BRUSH)     
wcx.lpszMenuName  = strptr ""
wcx.lpszClassName = strptr Classname
wcx.hIconSm       = 0

RegisterClassEx wcx
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

wcaption  = "MyWindowEx"
'create window -------------------------------
Hwnd = CreateWindowEx 0,ClassName , wcaption, style, Wx, Wy, Ww, Wh, wparent, 0, inst,0
ShowWindow Hwnd,SW_SHOW

' status bar
Int SBar, SBID = 101

Macro HiWord(a)
(0xffff And (a>>16))
End Macro

Macro LoWord(a)
 (a And 0xffff)
End Macro

'message loop-----------------
WHILE GetMessage(wm,0,0,0)
     TranslateMessage wm
     DispatchMessage  wm
WEND

'main callback procedure ---------------------------------------
Function WndProc(sys hwnd, wMsg, wParam, lParam) As sys callback
  Select wMsg
    Case WM_CREATE
      LBox = CreateWindowEx WS_EX_CLIENTEDGE, "ListBox", "", WS_CHILD + WS_VISIBLE + LBS_NOINTEGRALHEIGHT, lbx, lby, lw, lh, Hwnd, LBID, 0, 0
      SendMessage LBox, LB_ADDSTRING, 0, "Some"
      SendMessage LBox, LB_ADDSTRING, 0, "listbox"
      SendMessage LBox, LB_ADDSTRING, 0, "strings"
      SendMessage LBox, LB_ADDSTRING, 0, "added"
      SendMessage LBox, LB_ADDSTRING, 0, "for"
      SendMessage LBox, LB_ADDSTRING, 0, "your"
      SendMessage LBox, LB_ADDSTRING, 0, "enjoyment"
      SBar = CreateWindowEx 0, "MSCtls_StatusBar32", "Ready...", WS_CHILD + WS_VISIBLE, 0, 0, 0, 0, Hwnd, SBID, 0, 0
     
    Case WM_SIZE
      MoveWindow LBox, lbx, lby, LoWord(lParam) - 40, HiWord(lParam) - 50, 1
      SendMessage SBar, WM_SIZE, 0, 0
     
    Case WM_DESTROY
      PostQuitMessage 0
  End Select
  'never put default return inside select
  Return DefWindowProc(Hwnd, wMsg, wParam, lParam)
End Function
'-----------------------------------------
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 24, 2015, 09:13:46 AM
Mike
my code contain bug  :o
but your even don't show status bar  :o :o :o
 ;D
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 24, 2015, 11:10:02 AM
my code contain bug  :o

Here's how you create your controls:
Quote
LBox = CreateWindowEx 0x200,"LISTBOX","", 0x50000140, lbx, lby, lw, lh, Hwnd, 0,0,LBID

and here's how they must be created:
Quote
LBox = CreateWindowEx WS_EX_CLIENTEDGE, "ListBox", "", WS_CHILD + WS_VISIBLE + LBS_NOINTEGRALHEIGHT, lbx, lby, lw, lh, Hwnd, LBID, 0, 0

Watch out for your control ID argument positions the next time you land in front of your PC to code something.


but your even don't show status bar  :o :o :o

Ya trollin' an' tryin' to make a fool of me again, man? Watch yet another one of my videos then, you seem to be so fond of them, doncha?

Please stop that, Aurel, or I won't respond to your questions ever again.

.
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 24, 2015, 12:20:02 PM
Yes you have right about wrong position of LBID and i made mistake
but i really ...really ...don't get it why statusbar is not visible this time ( oxygen code).
and there is no joke...
it looks if status control is called from include file like awinh then
is visible
but if is created directly then nothing ?????
strange..


Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 24, 2015, 12:26:32 PM
Aurel,

Why didn't you download my zip?
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 24, 2015, 12:36:03 PM
Ok downloading ....
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 24, 2015, 12:39:06 PM
Now I see. I hope my exe works on your PC as expected?
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 24, 2015, 12:47:17 PM
No ..not work...i really dont get it why?
As i say i see your video and see that status is created but
when i run your exe then there is no statusBar and
i repeat this is not any kind of joke ...maybe is problem in Oxygen ..who knows?
And i repeat again...
if status bar is created from include file then work but directly after listbox not work
crazy... :o

here is my code:
Code: [Select]
'skeleton VB way...
$ filename "skeleton.exe"
include "rtl32.inc"
'#lookahead
'structures
Type WNDCLASSEX
 cbSize        as int
 Style         as int
 lpfnwndproc   as sys
 cbClsextra    as int
 cbWndExtra    as int
 hInstance     as sys
 hIcon         as sys
 hCursor       as sys
 hbrBackground as sys
 lpszMenuName  as sys
 lpszClassName as sys
 hIconSm       AS sys
End Type

Type POINTAPI
 x as long
 y as long
End Type

Type MSG
 hwnd    as sys
 message as int
 wParam  as sys
 lParam  as sys
 time    as dword
 pt      as POINTAPI
End Type

Type RECT
 Left   as Long
 Top    as Long
 Right  as Long
 Bottom as Long
End Type



'constants
% IDI_WINLOGO     = 32517
% IDI_APPLICATION = 32512
% IDC_ARROW       = 32512
% CS_OWNDC        = 32
% CS_DBLCLKS      =  &H8
% SW_NORMAL       = 1
% SW_SHOW         = 5

% WM_CREATE      = 1
% WM_DESTROY     = 2
% WM_PAINT       = 15
% WM_QUIT        = 18
% WM_SIZE        = 5
% WM_MOVE        = 3
% WM_CHAR        = 258
% WM_KEYDOWN     = 256
% WM_KEYUP       = 257
% WM_MOUSEMOVE   = 512
% WM_MBUTTONDOWN = 519
% WM_LBUTTONDOWN = 513
% WM_RBUTTONDOWN = 516
% WM_LBUTTONUP   = 514
% WM_RBUTTONUP   = 517
% WM_MBUTTONUP   = 520


% WS_OVERLAPPEDWINDOW = 0x00CF0000
% WS_SYSMENU     = 0x80000
% WS_OVERLAPPED  = WS_SYSMENU     
% WS_POPUP       = 0x80000000
% WS_DLGFRAME    = 0x400000
% WS_VISIBLE     = 0x10000000
% WS_CHILD       = 0x40000000

% WS_CLIPSIBLINGS = 0x4000000
% WS_CLIPCHILDREN = 0x2000000

% LB_ADDSTRING   = 0x180
'statusbar constants
% SBARS_SIZEGRIP = 0x100

'defines...
SYS WHITE_BRUSH = 0

'declarations...
Declare Function LoadIcon         Lib "user32.dll"   Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As Any) As Long
Declare Function LoadCursor       Lib "user32.dll"   Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As Long
Declare Function GetModuleHandle  Lib "kernel32.dll" Alias "GetModuleHandleA" (sys lpModuleName) as Long
Declare Function RegisterClassEx  Lib "user32.dll"   Alias "RegisterClassExA" (byref lpwcx as WNDCLASSEX) as Long
Declare Function CreateWindowEx   Lib "user32.dll"   Alias "CreateWindowExA" (byval dwExStyle AS INT,byval lpClassName AS STRING,byval lpWindowName AS STRING,byval dwStyle AS INT,byval x AS INT,byval y AS INT,byval nWidth AS INT,byval nHeight AS INT,byval hWndParent AS INT,byval hMenu AS INT,byval hInstance AS INT,byval lpParam AS INT) as Long
Declare Function TranslateMessage Lib "user32.dll"  (byref lpMsg as MSG) as Long
Declare Function DispatchMessage  Lib "user32.dll"   Alias "DispatchMessageA" (byref lpMsg as MSG) as Long
Declare Function GetMessage       Lib "user32.dll"   Alias "GetMessageA" (lpMsg As MSG, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Declare Function ShowWindow       Lib "user32.dll"  (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Declare Function UpdateWindow     Lib "user32.dll"  (ByVal lhwnd As Long) As Long
Declare Function MoveWindow       Lib "user32.dll" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Declare Function DefWindowProc    Lib "user32.dll"  Alias "DefWindowProcA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Sub PostQuitMessage       Lib "user32.dll"  (ByVal nExitCode As Long)
Declare Function GetClientRect  Lib "user32.dll" (ByVal hwnd As sys, ByRef lpRect As RECT) As Long

Declare Function GetStockObject Lib "gdi32.dll" (ByVal nIndex As Long) As Long

Declare Function SendMessage     Lib "User32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function CreatePopupMenu Lib "user32.dll" () As Long
Declare Function CreateMenu      Lib "user32.dll" () As Long
Declare Function GetMenu         Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function SetMenu         Lib "user32.dll" (ByVal hwnd As Long, ByVal hMenu As Long) As Long
Declare Function AppendMenu      Lib "user32.dll" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Declare Function DrawMenuBar     Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function DeleteMenu      Lib "user32.dll" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Declare Function DestroyMenu     Lib "user32.dll" (ByVal hMenu As Long) As Long
Declare Function TrackPopupMenu  Lib "user32.dll" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hwnd As Long, lprc As RECT) As Long

Declare Function GetSize(int window , winX as int, winY as int, winW as int, winH as int)

Dim wcx as WNDCLASSEX
Dim wm as MSG
Dim hwnd,style, Wx, Wy, Ww, Wh, wparent as Long
Dim wcaption,ClassName,cr as String
Dim rc as RECT
cr=chr(10)
'wcaption  = "MyWindow"
classname = "Oxygen"
style   = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN
Wx=0 : Wy=0 : Ww=640 : Wh=480
wparent = 0 'HWND_DESKTOP
'listbox def -------------------------------
INT LBox,lbx=20,lby=20,lw=300,lh=200,LBID=100
'RECT def -----------------------
INT Lx,Ty,Hs,Vs

'FILL WNDCLASSEX structure
inst = GetModuleHandle 0
wcx.cbSize        = sizeOf(WNDCLASSEX)
wcx.style         = CS_DBLCLKS
wcx.lpfnWndProc   = &WndProc
wcx.cbClsExtra    = 0
wcx.cbWndExtra    = 0
wcx.hInstance     = inst
wcx.hIcon         = LoadIcon 0,IDI_APPLICATION         
wcx.hCursor       = LoadCursor 0,IDC_ARROW 
wcx.hbrBackground = GetStockObject(WHITE_BRUSH)     
wcx.lpszMenuName  = strptr ""
wcx.lpszClassName = strptr Classname
wcx.hIconSm       = 0

RegisterClassEx wcx

wcaption  = "MyWindowEx"
'create window -------------------------------
Hwnd = CreateWindowEx 0,ClassName , wcaption, style, Wx, Wy, Ww, Wh, wparent, 0, inst,0
ShowWindow Hwnd,SW_SHOW
'create listbox
LBox = CreateWindowEx 0x200,"LISTBOX","", 0x50000140, lbx, lby, lw, lh, Hwnd, LBID,0,0
SendMessage LBox, LB_ADDSTRING, 0,strptr "Some"
SendMessage LBox, LB_ADDSTRING, 0,strptr "listbox"
SendMessage LBox, LB_ADDSTRING, 0,strptr "strings"
SendMessage LBox, LB_ADDSTRING, 0,strptr "added"
SendMessage LBox, LB_ADDSTRING, 0,strptr "for you"

' status bar
Int SBar, SBID = 110
SBar = CreateWindowEx 0x200, "msctls_statusbar32", "!status bar", 1409286400 , 0, 0, 0, 0, Hwnd, SBID, 0, 0

'message loop-----------------
WHILE GetMessage(wm,0,0,0)
     TranslateMessage wm
     DispatchMessage  wm
WEND

'main callback procedure ---------------------------------------
Function WndProc (sys hwnd,wMsg,wParam,lParam) as sys callback
Select wMsg

Case WM_SIZE
     GetSize(Hwnd , Lx, Ty, Hs, Vs)   
MoveWindow (LBox, lbx , lby, Hs-40, Vs-80, 1)
     SendMessage SBar, WM_SIZE, 0, 0

Case WM_DESTROY
PostQuitMessage 0

End Select
'never put default return inside select
Return DefWindowProc(Hwnd,wMsg,wParam,lParam)

End Function
'------------------------------------------

'GetClientsize --------------------------------------------------------------------------------
SUB GetSize(int window , winX as int, winY as int, winW as int, winH as int)
GetClientRect( window, rc)
'hndx=0:hndy=0:hndw=0:hndh=0
winX = rc.Left
winY = rc.top
winW = rc.right
winH = rc.bottom
'Return rc
End SUB
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 24, 2015, 12:52:44 PM
I am talking about skeleton.exe that's in the zip, not about my script that's in there too, or your script that you've just posted. Please double click on skeleton.exe. Does it show both the listbox and the statusbar? Does the listbox display its text lines?
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 24, 2015, 12:58:01 PM
Yes ...
i know i am not kid ...
listbox is here but there is no statusbar ...and it looks i figured why is not
i forget that in include file is:
Quote
As with all common controls, you must call InitCommonControls() BEFORE you try and use them. You will need to #include <commctrl.h> in order to use this function and to get the functions and declarations necessary for use of the Common Controls. You will also need to add comctl32.lib to your linker settings if it is not already there. Note that InitCommonControls() is an older API, and for more control you can use InitCommonControlsEx() (aka InitCommonControlSex()) which is also required for the most recent common controls. However since I'm not using any of the advanced features, InitCommonControls() is adequate and simpler.

sooo that why work from include and why not from my code
sorry man what kind of trouble for nothing ...
i will resolved this tomorow....
good night ....


PS ..this is the missing thing:

dim comctl32 = LoadLibrary "comctl32.dll"
oh what a mumbo jumbo
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 24, 2015, 01:01:58 PM
Please tell me tomorrow if the listbox in my skeleton.exe shows the "Some listbox strings added for your enjoyment" message in its lines for you.

Have a good rest, Aurel. :)
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 25, 2015, 04:42:36 AM
Hi Mike
yes your skeleton-exe work ok ...listbox work ok
but as i say there is no status control because
missing :
dim comctl32 = LoadLibrary "comctl32.dll"

so when i add this in my program then work everything  :D

Code: [Select]
'skeleton VB way...
$ filename "skeleton.exe"
include "rtl32.inc"
'#lookahead
'structures
Type WNDCLASSEX
 cbSize        as int
 Style         as int
 lpfnwndproc   as sys
 cbClsextra    as int
 cbWndExtra    as int
 hInstance     as sys
 hIcon         as sys
 hCursor       as sys
 hbrBackground as sys
 lpszMenuName  as sys
 lpszClassName as sys
 hIconSm       AS sys
End Type

Type POINTAPI
 x as long
 y as long
End Type

Type MSG
 hwnd    as sys
 message as int
 wParam  as sys
 lParam  as sys
 time    as dword
 pt      as POINTAPI
End Type

Type RECT
 Left   as Long
 Top    as Long
 Right  as Long
 Bottom as Long
End Type



'constants
% IDI_WINLOGO     = 32517
% IDI_APPLICATION = 32512
% IDC_ARROW       = 32512
% CS_OWNDC        = 32
% CS_DBLCLKS      =  &H8
% SW_NORMAL       = 1
% SW_SHOW         = 5

% WM_CREATE      = 1
% WM_DESTROY     = 2
% WM_PAINT       = 15
% WM_QUIT        = 18
% WM_SIZE        = 5
% WM_MOVE        = 3
% WM_CHAR        = 258
% WM_KEYDOWN     = 256
% WM_KEYUP       = 257
% WM_MOUSEMOVE   = 512
% WM_MBUTTONDOWN = 519
% WM_LBUTTONDOWN = 513
% WM_RBUTTONDOWN = 516
% WM_LBUTTONUP   = 514
% WM_RBUTTONUP   = 517
% WM_MBUTTONUP   = 520


% WS_OVERLAPPEDWINDOW = 0x00CF0000
% WS_SYSMENU     = 0x80000
% WS_OVERLAPPED  = WS_SYSMENU     
% WS_POPUP       = 0x80000000
% WS_DLGFRAME    = 0x400000
% WS_VISIBLE     = 0x10000000
% WS_CHILD       = 0x40000000

% WS_CLIPSIBLINGS = 0x4000000
% WS_CLIPCHILDREN = 0x2000000

% LB_ADDSTRING   = 0x180
'statusbar constants
% SBARS_SIZEGRIP = 0x100

'defines...
SYS WHITE_BRUSH = 0

'declarations...
Declare Function LoadIcon         Lib "user32.dll"   Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As Any) As Long
Declare Function LoadCursor       Lib "user32.dll"   Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As Long
Declare Function GetModuleHandle  Lib "kernel32.dll" Alias "GetModuleHandleA" (sys lpModuleName) as Long
Declare Function RegisterClassEx  Lib "user32.dll"   Alias "RegisterClassExA" (byref lpwcx as WNDCLASSEX) as Long
Declare Function CreateWindowEx   Lib "user32.dll"   Alias "CreateWindowExA" (byval dwExStyle AS INT,byval lpClassName AS STRING,byval lpWindowName AS STRING,byval dwStyle AS INT,byval x AS INT,byval y AS INT,byval nWidth AS INT,byval nHeight AS INT,byval hWndParent AS INT,byval hMenu AS INT,byval hInstance AS INT,byval lpParam AS INT) as Long
Declare Function TranslateMessage Lib "user32.dll"  (byref lpMsg as MSG) as Long
Declare Function DispatchMessage  Lib "user32.dll"   Alias "DispatchMessageA" (byref lpMsg as MSG) as Long
Declare Function GetMessage       Lib "user32.dll"   Alias "GetMessageA" (lpMsg As MSG, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Declare Function ShowWindow       Lib "user32.dll"  (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Declare Function UpdateWindow     Lib "user32.dll"  (ByVal lhwnd As Long) As Long
Declare Function MoveWindow       Lib "user32.dll" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Declare Function DefWindowProc    Lib "user32.dll"  Alias "DefWindowProcA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Sub PostQuitMessage       Lib "user32.dll"  (ByVal nExitCode As Long)
Declare Function GetClientRect  Lib "user32.dll" (ByVal hwnd As sys, ByRef lpRect As RECT) As Long

Declare Function GetStockObject Lib "gdi32.dll" (ByVal nIndex As Long) As Long

Declare Function SendMessage     Lib "User32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function CreatePopupMenu Lib "user32.dll" () As Long
Declare Function CreateMenu      Lib "user32.dll" () As Long
Declare Function GetMenu         Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function SetMenu         Lib "user32.dll" (ByVal hwnd As Long, ByVal hMenu As Long) As Long
Declare Function AppendMenu      Lib "user32.dll" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Declare Function DrawMenuBar     Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function DeleteMenu      Lib "user32.dll" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Declare Function DestroyMenu     Lib "user32.dll" (ByVal hMenu As Long) As Long
Declare Function TrackPopupMenu  Lib "user32.dll" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hwnd As Long, lprc As RECT) As Long

Declare Function GetSize(int window , winX as int, winY as int, winW as int, winH as int)

dim comctl32 = LoadLibrary "comctl32.dll"

Dim wcx as WNDCLASSEX
Dim wm as MSG
Dim hwnd,style, Wx, Wy, Ww, Wh, wparent as Long
Dim wcaption,ClassName,cr as String
Dim rc as RECT
cr=chr(10)
'wcaption  = "MyWindow"
classname = "Oxygen"
style   = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN
Wx=0 : Wy=0 : Ww=640 : Wh=480
wparent = 0 'HWND_DESKTOP
'listbox def -------------------------------
INT LBox,lbx=20,lby=20,lw=300,lh=200,LBID=100
'RECT def -----------------------
INT Lx,Ty,Hs,Vs

'FILL WNDCLASSEX structure
inst = GetModuleHandle 0
wcx.cbSize        = sizeOf(WNDCLASSEX)
wcx.style         = CS_DBLCLKS
wcx.lpfnWndProc   = &WndProc
wcx.cbClsExtra    = 0
wcx.cbWndExtra    = 0
wcx.hInstance     = inst
wcx.hIcon         = LoadIcon 0,IDI_APPLICATION         
wcx.hCursor       = LoadCursor 0,IDC_ARROW 
wcx.hbrBackground = GetStockObject(WHITE_BRUSH)     
wcx.lpszMenuName  = strptr ""
wcx.lpszClassName = strptr Classname
wcx.hIconSm       = 0

RegisterClassEx wcx

wcaption  = "MyWindowEx"
'create window -------------------------------
Hwnd = CreateWindowEx 0,ClassName , wcaption, style, Wx, Wy, Ww, Wh, wparent, 0, inst,0
ShowWindow Hwnd,SW_SHOW

'create listbox
LBox = CreateWindowEx 0x200,"LISTBOX","", 0x50000140|WS_CLIPSIBLINGS, lbx, lby, lw, lh, Hwnd, LBID,0,0
SendMessage LBox, LB_ADDSTRING, 0,strptr "Some"
SendMessage LBox, LB_ADDSTRING, 0,strptr "listbox"
SendMessage LBox, LB_ADDSTRING, 0,strptr "strings"
SendMessage LBox, LB_ADDSTRING, 0,strptr "added"
SendMessage LBox, LB_ADDSTRING, 0,strptr "for you"

' status bar
Int SBar, SBID = 110
SBar = CreateWindowEx 0x200, "msctls_statusbar32", "_Status_Bar:", 1409286400 , 0, 0, 0, 0, Hwnd, SBID, 0, 0


'message loop-----------------
WHILE GetMessage(wm,0,0,0)
     TranslateMessage wm
     DispatchMessage  wm
WEND

'main callback procedure ---------------------------------------
Function WndProc (sys hwnd,wMsg,wParam,lParam) as sys callback
Select wMsg

Case WM_SIZE
     GetSize(Hwnd , Lx, Ty, Hs, Vs)   
MoveWindow (LBox, lbx , lby, Hs-40, Vs-80, 1)
     SendMessage SBar, WM_SIZE, 0, 0

Case WM_DESTROY
PostQuitMessage 0

End Select
'never put default return inside select
Return DefWindowProc(Hwnd,wMsg,wParam,lParam)

End Function
'------------------------------------------

'GetClientsize --------------------------------------------------------------------------------
SUB GetSize(int window , winX as int, winY as int, winW as int, winH as int)
GetClientRect( window, rc)
'hndx=0:hndy=0:hndw=0:hndh=0
winX = rc.Left
winY = rc.top
winW = rc.right
winH = rc.bottom
'Return rc
End SUB
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Mike Lobanovsky on October 25, 2015, 07:43:14 AM
Hi Aurel,

Thanks for responding.

... but as i say there is no status control because missing :
dim comctl32 = LoadLibrary "comctl32.dll"

Under my XP Sp3 and all Windows higher than that, this isn't necessary. My script as well as your latest script you've just posted above run perfectly well here without this comctl32 hack both in the JIT mode and statically compiled to respective executables.

I would still recommend you not use your GetSize() in the WM_SIZE handler because it is redundant. The lParam value for this message contains the window client area's current width and height. Just get them with the help of HiWord()/LoWord() macros as I'm doing in my script. Those macros have been written by Charles (not me ;) ) so you may use them without hesitation. They work much, much faster than your nested function calls giving you the exact same values. 

Quote
... so when i add this in my program then work everything  :D

That's great! I can imagine that feeling when everyone is swimming in the sea while you have to sit ashore because you have no swimming trunks.

Anyway, good to hear your interpreter's tool palette will now include two more user controls. :)
Title: Re: STATUSBAR - FLICKER FREE?
Post by: Aurel on October 25, 2015, 09:29:13 AM
Hi Mike

Quote
Anyway, good to hear your interpreter's tool palette will now include two more user controls
I don't do that for my interpreter,but in first place because Oxygen basic and for testing
include files with WNDCLASSEX.
I really don't have to much free time for programming this days or i am to tired to thinking
about that...to much work before winter comes  ::)

Ahh those macros i already use them..nothing new  ;)