C0D3

_WinAPI_BitBlt and Status Bar in Resizable GUI Problem

13 posts in this topic

hey Autoit Community,
i have a question , but i don't really know if here is the right section to post it ( if it is not please relocate it to the right site )
i have created a program which have tow sides ,Server and Client
my problem is that am using  _WinAPI_BitBlt  Function to put the image i received on my GUI ( the function itself works fine and dose the job)
when i implemented a status bar on my GUI the problem occurs
the image is painted at all the GUI and over the status bar so i changed the
old code line from

_WinAPI_BitBlt($gui_get_dc , 0, 0, $i_width, $i_height, $cb_hdc, 0, 0,$srccopy)

to the new code line

_WinAPI_BitBlt($gui_get_dc , 0, 0, $i_width, $i_height -23, $cb_hdc, 0, 0,$srccopy)


after that the status bar appears just fine, the problem with this method is the image will lose a part of it's bottom
i was searching over the internet for the last 5 hours for a solution and the help File , and found Nothing
so please if anyone have an idea of how i can fix that, or how to draw with _WinAPI_BitBlt in a specific area of my GUI( resizable GUI)
thanks in advance for any kind of help :D

Share this post


Link to post
Share on other sites



and within the help file **

so please if anyone have an idea of how i can fix that, or how to draw with _WinAPI_BitBlt in a specific area of my GUI( resizable GUI)  i will be grateful **
 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Increase the GUI height by 23 only and use

$i_width = 800
$i_height = 600

$hGUI = GUICreate("Test", $i_width, $i_height + 23)
...


_WinAPI_BitBlt($gui_get_dc , 0, 0, $i_width, $i_height, $cb_hdc, 0, 0,$srccopy)

instead of $i_height - 23.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites
3 hours ago, UEZ said:

Increase the GUI height by 23 only and use

$i_width = 800
$i_height = 600

$hGUI = GUICreate("Test", $i_width, $i_height + 23)
...


_WinAPI_BitBlt($gui_get_dc , 0, 0, $i_width, $i_height, $cb_hdc, 0, 0,$srccopy)

instead of $i_height - 23.

i did that already with no Success, the image will be still printed on all of the GUI including the Status bar ( which will be flickering all the time when the new data received )

Share this post


Link to post
Share on other sites

Can you write a short reproducer of your problem?


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites
3 hours ago, AndyG said:

i know it should do the job, i thought at the beginning it will exclude the status bar automatically but it didn't, and when i tried to fix that i ended up with an image which lost apart of its bottom.

the function it self is working as it should but the problem is that it is still printing the image on the status bar no matter what i do

Share this post


Link to post
Share on other sites
22 minutes ago, UEZ said:

Can you write a short reproducer of your problem?

i tired to take a part of my code ... if this isn't engoh for trying to fix the problem let me know ( although i wanted to release it like a working example ..)

this is not a working example it is just a part of the whole Code

 

$STREAM_GUI = GUICreate($GUI_STREAM_DESKTOP, $I_WIDTH, $I_HEIGHT, -1, -1, $WS_SIZEBOX)
$GUI_GET_DC = _WinAPI_GetDC($STREAM_GUI)


Func RECEIVE_STREAM()
    $CB_HDC                = CREAT_BITMAP($I_WIDTH, $I_HEIGHT, $PTR_BMP, $IS_BMP_H)
    $CREATE_INFO_STRUCTURE = DllStructCreate("byte[" & $I_WIDTH * $I_HEIGHT * 7 & "]")
    $GETPTR_INFO_STRUCTURE = DllStructGetPtr($CREATE_INFO_STRUCTURE)
    $DLL_SCREATE_PIC       = DllStructCreate("byte[" & $I_WIDTH * $I_HEIGHT * 4 & "]",$PTR_BMP)
    $BMP_SIZE              = $I_WIDTH * $I_HEIGHT
    $INPUT                 = DllStructCreate("byte[" & $BMP_SIZE * 7 & "]")
    $IS_BUFFER             = DllStructCreate("byte[" & 16 * $BMP_SIZE * 5 & "]")
    $PTR_BUFFER            = DllStructGetPtr($IS_BUFFER)
    $PTR_INPUT             = DllStructGetPtr($INPUT )
WHILE 1
              $GET_DATA    = (GET_INFO_LENGHT(FALSE))
              $GET_DATA    = DE_COMPRESS($GET_DATA)
              $DATA_LENGTH = @EXTENDED
           IF $DATA_LENGTH > 0 Then
                            DllStructSetData($CREATE_INFO_STRUCTURE,1,$GET_DATA)
                            DllCall($USER32_DLL,"int","CallWindowProcW","ptr",$P_CODE,"ptr",$PTR_BMP,"ptr",$GETPTR_INFO_STRUCTURE,"int",$DATA_LENGTH,"int",$BMP_SIZE)
$FIXED_I_HEIGHT = $I_HEIGHT+23 ; Partly fix the problem ( the image lose a part of its bottom .. need to fix it damn spend some time on it for future knowledge )
                        _WinAPI_BitBlt($GUI_GET_DC,0,0,$I_WIDTH,$FIXED_I_HEIGHT,$CB_HDC,0,0,$SRCCOPY)
$FIXED_I_HEIGHT = 0
           EndIF
WEnd
EndFunc


Func CREAT_BITMAP($IS_WIDTH,$IS_HEIGHT,ByRef $PTR,ByRef $IS_BMP) ; not my own function
$CCDC = _WinAPI_CreateCompatibleDC(0) ; if this handle is 0, the function creates a memory DC compatible with the application's current screen.
$BITMAP_CREATE_STRUCTURE = DllStructCreate($tagBITMAPINFO)
                           DllStructSetData($BITMAP_CREATE_STRUCTURE,1, DllStructGetSize($BITMAP_CREATE_STRUCTURE) - 4)
                           DllStructSetData($BITMAP_CREATE_STRUCTURE,2, $IS_WIDTH)
                           DllStructSetData($BITMAP_CREATE_STRUCTURE,3, -$IS_HEIGHT) ; minus = up side dwon ( remove it for and output of upside down )
                           DllStructSetData($BITMAP_CREATE_STRUCTURE,4, 1)
                           DllStructSetData($BITMAP_CREATE_STRUCTURE,5, 32)
$DIB_SECTION = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($BITMAP_CREATE_STRUCTURE), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'uint', 0)
$IS_BMP = $DIB_SECTION[0]
;~ $PTR    = $DIB_SECTION[4]
_WinAPI_SelectObject($CCDC, $IS_BMP)
       Return $CCDC
EndFunc

Note : all variables are list as Global ...

Share this post


Link to post
Share on other sites

i am trying to fix it right now using _WinAPI_GetDCEx() function... i will post here in either ways ( success/Failure)...

Share this post


Link to post
Share on other sites

You can try something like this here:

#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
#include <ScreenCapture.au3>

Global $I_WIDTH = 800
Global $I_HEIGHT = 600
Global $STREAM_GUI = GUICreate("Test", $I_WIDTH, $I_HEIGHT, -1, -1, $WS_SIZEBOX)
Global $STATUSBAR = _GUICtrlStatusBar_Create($STREAM_GUI)

_GUICtrlStatusBar_SetText($STATUSBAR, "Test")
$hHBITMAP = _ScreenCapture_Capture("", 1, 1, $I_WIDTH, $I_HEIGHT)
$GUI_GET_DC = _WinAPI_GetDC($STREAM_GUI)
$CB_HDC = _WinAPI_CreateCompatibleDC($GUI_GET_DC) ;creates a memory device context compatible with the specified device
$DC_Obj = _WinAPI_SelectObject($CB_HDC, $hHBITMAP)
GUISetState()
$aWin = WinGetClientSize($STREAM_GUI)
_WinAPI_BitBlt($GUI_GET_DC, 0, 0, $I_WIDTH, $aWin[1] - 24, $CB_HDC, 0, 0, $SRCCOPY)

Do
    Switch GUIGetMsg()
        Case -3
            _WinAPI_DeleteObject($hHBITMAP)
            _WinAPI_CreateCompatibleDC($CB_HDC)
            _WinAPI_SelectObject($CB_HDC, $DC_Obj)
            _WinAPI_ReleaseDC($STREAM_GUI, $GUI_GET_DC)
            GUIDelete()
            Exit
    EndSwitch
Until False

 


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites
5 hours ago, UEZ said:

You can try something like this here:

#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
#include <ScreenCapture.au3>

Global $I_WIDTH = 800
Global $I_HEIGHT = 600
Global $STREAM_GUI = GUICreate("Test", $I_WIDTH, $I_HEIGHT, -1, -1, $WS_SIZEBOX)
Global $STATUSBAR = _GUICtrlStatusBar_Create($STREAM_GUI)

_GUICtrlStatusBar_SetText($STATUSBAR, "Test")
$hHBITMAP = _ScreenCapture_Capture("", 1, 1, $I_WIDTH, $I_HEIGHT)
$GUI_GET_DC = _WinAPI_GetDC($STREAM_GUI)
$CB_HDC = _WinAPI_CreateCompatibleDC($GUI_GET_DC) ;creates a memory device context compatible with the specified device
$DC_Obj = _WinAPI_SelectObject($CB_HDC, $hHBITMAP)
GUISetState()
$aWin = WinGetClientSize($STREAM_GUI)
_WinAPI_BitBlt($GUI_GET_DC, 0, 0, $I_WIDTH, $aWin[1] - 24, $CB_HDC, 0, 0, $SRCCOPY)

Do
    Switch GUIGetMsg()
        Case -3
            _WinAPI_DeleteObject($hHBITMAP)
            _WinAPI_CreateCompatibleDC($CB_HDC)
            _WinAPI_SelectObject($CB_HDC, $DC_Obj)
            _WinAPI_ReleaseDC($STREAM_GUI, $GUI_GET_DC)
            GUIDelete()
            Exit
    EndSwitch
Until False

hey UEZ

thank you for your effort i appreciate it
the example you gave dose what it have to do and it is nearly what i did before but thank you for trying to help me :D
i came up with a solution to the problem ... i combined the 2 functions ( BitBlt , StretchBlt ) in one Working Function
i know it sounds/looks stupid but here it is

Func WinAPI_Stretch_BitBlt($DESTINATION_DEVICE, $X_DESTINATION, $Y_DESTINATION, $WIDTH_DESTINATION, $HEIGH_DESTINATION, $SOURCE_DEVICE, $X_SOURCE, $Y_SOURCE,$WIDTH_SOURCE,$HEIGHT_SOURCE, $RASTER_OPERATION)
Local $BitBlt,$StretchBlt,$Error_BitBlt,$Error_StretchBlt,$FINAL_Error
$BitBlt = DllCall("Gdi32.dll","bool","BitBlt","handle",$DESTINATION_DEVICE,"int",$X_DESTINATION,"int",$Y_DESTINATION,"int",$WIDTH_DESTINATION,"int",$HEIGH_DESTINATION,"handle",$SOURCE_DEVICE,"int",$X_SOURCE,"int",$Y_SOURCE,"dword",$RASTER_OPERATION)
    IF @ERROR Then $Error_BitBlt = False
$StretchBlt = DllCall("Gdi32.dll","int","StretchBlt","hwnd",$DESTINATION_DEVICE,"int",$X_DESTINATION,"int",$Y_DESTINATION,"int",$WIDTH_DESTINATION,"int",$HEIGH_DESTINATION,"hwnd",$SOURCE_DEVICE,"int",$X_SOURCE,"int",$Y_SOURCE,"int",$WIDTH_SOURCE,"int",$HEIGHT_SOURCE,"dword",$RASTER_OPERATION)
    IF @ERROR Then $Error_StretchBlt = False
$FINAL_Error = $Error_BitBlt &" \ " & $Error_StretchBlt
IF NOT @ERROR Then
    Return $StretchBlt[0]
Else
    Return $FINAL_Error
EndIF
EndFunc ; by C0D3

and the line which Solved The whole problem is
 

WinAPI_Stretch_BitBlt($GUI_GET_DC,0,-24, $I_WIDTH, $I_HEIGHT, $CB_HDC,0,-24,$I_WIDTH,$I_HEIGHT+24, $SRCCOPY) ; 24 = Status Bar Height

i hope this function will help someone someday :)
best regards

 

Share this post


Link to post
Share on other sites

Hi,

it should be mentioned that StretchBlt() is way slower when used the HALFTONE by SetStretchBltMode! But the result is much better!

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now