Page 1 of 2 12 LastLast
Results 1 to 40 of 58

Thread: How to take a picture from the back of the form while the form is being displayed to?

  1. #1

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    How to take a picture from the back of the form while the form is being displayed to?

    i found some codes about how can take screen shot of form or desktop and esc, now how to take a picture from the back of the form while the form is being displayed to the user? if i want to hide or minimize or change location of the form, the user will see a flashing form. Is it possible to do this without any delay in the user's view?

    i dont want use aero glass windows because sometimes it disbaled by user or i want to make some different effect and add some objects and etc,I tried to make an example (i applied blur effect too) but its not good



    Last edited by Black_Storm; Jan 24th, 2023 at 06:47 AM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: How to take a picture from the back of the form while the form is being displayed

    Quote Originally Posted by Black_Storm View Post
    if i want to hide or minimize or change location of the form, the user will see a flashing form[/CENTER]
    In the past it was used LockWindowUpdate to hide those artifacts. Not sure if it still works.

  3. #3

  4. #4

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed


    When I move the form or move the forms under the program, the image inside the form remains fixed, it seems that it needs a timer to work properly, because CallWindowProc is used and there are controls in the program. It has been used that they also use CallWindowProc, may be slow speed or a problem in execution?
    Last edited by Black_Storm; Jan 25th, 2023 at 12:53 AM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  5. #5

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    Quote Originally Posted by Eduardo- View Post
    In the past it was usedLockWindowUpdate to hide those artifacts. Not sure if it still works.
    how can use in about this thread? i cant find any sample about how can take screen shot of behind form without flicker
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  6. #6
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: How to take a picture from the back of the form while the form is being displayed

    Quote Originally Posted by Black_Storm View Post
    how can use in about this thread? i cant find any sample about how can take screen shot of behind form without flicker
    Take the shot before showing the form.

    But regarding LockWindowUpdate, I'm not sure if it would work for that (I'm not sure if it is currently working at all BTW).

  7. #7

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    Taking a photo of the form before it is seen, especially when a standard form is not used and all the content is displayed on a layered canvas on the desktop, was a question that I followed here before:

    [RESOLVED] How can take screen shot of special area outside of desktop?


    I used the same method in post 1, of course, I had to do the same thing for the time when the user moves the form, but the blinking problem occurs.


    Assuming, for example, that a photo is taken before the (layered canvas as a form is displayed), but after the form is displayed, the user can move the form, or that regardless of the form, changes may be happening under the form at any moment (like appearing new windows or changes that are constantly being made under the form on the desktop and windows under the form) so the form must always be taking a photo (except for the photo of our desired form) so there is always a need for a timer .


    The problem is how to hide the form, take a picture, record the new changes of the windows and all the content of the bottom of the form, and then display the form again without creating a flashing state for the user. I am looking for an example project to do such a thing.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  8. #8
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: How to take a picture from the back of the form while the form is being displayed

    Why do you need to take this screenshot, anyway?

  9. #9

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    i doing design my custom skin form with controls and etc,It is my opinion that photography should always be taken
    Reason: to get the changes that are always happening under the form window of the program


    I want to design a part of my form, for example, the title part of the form, it can be any other part of my form in a way that looks like the glass mode of Windows, for example, blurred or apply other effects, and it is very important for me to be able to see the back of the form ( my means of back of the form is all windows under my form on dekstop and etc). and if a change happens behind the form window, it can be seen instantly
    Last edited by Black_Storm; Jan 25th, 2023 at 03:25 AM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  10. #10
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: How to take a picture from the back of the form while the form is being displayed

    Perhaps you'll have to find what windows are behind the form, take a screenshot of each one and compose them into a single image.

  11. #11

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    I had this idea in mind before asking my question, but there is no guarantee that it will work well because there can be different states under the form that are complicated, there may be animations or content that simply cannot be captured,

    Maybe in the same way that I am doing in the first post, there is a way that can solve this problem with a faster formula or with the help of some functions without the problem of blinking or faster processing.

    if i wanna activate timer in my post 1 there is need again to take shot from behind form and again same flicker problem over and over.

    Considering that you have worked in the field of graphics, maybe you can do a test or exercise or find an example that is useful.
    Last edited by Black_Storm; Jan 25th, 2023 at 04:27 AM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  12. #12
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: How to take a picture from the back of the form while the form is being displayed

    Why not just to use what Windows already offers about transparency? Just saying.

  13. #13

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    any solution that can have the output I want is appreciated, but I need a testable example, if you can use it (whatever purpose of transparency you have in mind) to design the output I want, a test do it, in addition, it is also important that other objects can be placed on the blurred part, which may only display the objects on the desired part incorrectly, for example, I have a label for the title part on I have put the blurred image in post 1 to you can see it "title" caption. It is also important that I used blurring as an example effect and it can include more effects because I am designing the blurring effect with gdiplus, so it can be other effects. can also be replaced with similar animated effects or other modes
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  14. #14
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,854

    Re: How to take a picture from the back of the form while the form is being displayed

    The example in this thread works for me both in IDE and compiled:
    https://www.vbforums.com/showthread....ible-controls)

  15. #15

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    How can this sample help with the output I need? I mean, where can it be used?
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  16. #16
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,854

    Re: How to take a picture from the back of the form while the form is being displayed

    You want your background to be transparent, don't you?

  17. #17

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    If what you mean by "transparent" is to make only a part of the form transparent so that that part is not visible and instead all the content below the form is displayed, then how can the content below the part that is transparent be affected, similar to the effect of blurring? Others, transparing can only remove the desired part, but it seems to me something like a photo of all the content under the form or a part of the form.

    i want can watch all window behind of my form as a image and then i apply some effects like as blue or other effects.

    let me explain again simple :
    If I want to give an example, design a form and make it look like Windows Glass, so that the user can move it on the desktop and the content behind it can be seen as blurred or glass-like, the user may move the windows under the form. or open a new window and similar to these and the form can display them instantly


    make something like as this forms :







    Name:  demo.jpg
Views: 561
Size:  28.0 KB
    and etc ...



    i found some apis like as SetWindowDisplayAffinity and WDA_EXCLUDEFROMCAPTURE parameter :
    SetWindowDisplayAffinity function (winuser.h) - Win32 apps | Microsoft Learn

    i could not find any sample in vb6 about this and i guess its not support in all windows,if it can be work on win 7 or newer its okay but i guess its work on win 10 or maybe win 8
    Last edited by Black_Storm; Jan 25th, 2023 at 09:28 AM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  18. #18
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: How to take a picture from the back of the form while the form is being displayed

    So, let's be clear: you want to show a form with some parts translucent (not totally transparent) but that the "light" that goes through it gets fuzzy, similar to a bathroom glass (to put an example).

    But... and here is the most difficult part, you want to it to be totally dynamic. If the figures that are behind move or change, that needs to be updated. If the user is moving your translucent form, the fuzzy background needs to be updated in real time, as the form is moved.

    In other words: the same or very similar to Windows Aero.

    If I'm understanding that correctly, then, I don't think that such a real time update could be done by "taking pictures" of the windows that are behind.

    Do you know of any program that does that? (besides Windows Aero that does it for the title bar)

    I would start studying the Desktop Window Manager. Maybe someone with experience with it can tell you, but I didn't see much about it here.
    Because that should be handled at low level to be really dynamic. From high level is already difficult to take e single picture without flicker.

  19. #19

  20. #20

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    i know about DwmEnableBlurBehindWindow ,i have too much samples about it but as i said in post 1 (my means of aero glass windows was been same use DwmEnableBlurBehindWindow):

    i dont want use aero glass windows because sometimes it disbaled by user or i want to make some different effect and add some objects and etc,I tried to make an example (i applied blur effect too) but its not good
    If I want to use DwmEnableBlurBehindWindow, on the condition that if I only want to use Windows Glass only and support the service in Windows or the Glass theme in that Windows, which of course can have a series of other problems. And I don't want to be this way :

    Code:
    
    Public Sub GlassifyForm(frm As Form)
    
    
      Dim aEn As MARGIN_STRUCT
    
    
      aEn.cxLeftWidth = -1
      aEn.cxRightWidth = -1
      aEn.cyTopHeight = -1
      aEn.cyBottomHeight = -1
    
    
      DwmIsCompositionEnabled 1
    
    
      DwmExtendFrameIntoClientArea frm.hWnd, aEn
    
    
    End Sub
    
    
    Private Sub Command1_Click()
    GlassifyForm Me
    End Sub
    
    
    Private Sub Command2_Click()
    Dim hr As Long
    Me.BackColor = RGB(100, 0, 0)
    Me.Refresh
    DoEvents
    hr = CreateEllipticRgn(0, 0, Width, Height)
    
    
    Dim dbb As DwmBlurbehind
    With dbb
    .FEnable = True
    .DwFlags = 1
    .HRgnBlur = hr
    .FTransitionOnMaximized = False
    End With
    DwmEnableBlurBehindWindow hWnd, dbb
    End Sub
    about
    Quote Originally Posted by Eduardo- View Post
    Do you know of any program that does that? (besides Windows Aero that does it for the title bar)


    i seen some apps in delphis special skins in delphi , in vb or other languages i seen some examples about magnifer to can work on pixels under main form and real time live like as sbutton in vb and :


    or some widgets and i guess it's like as these (maybe it's from your products) post 4(another magnifier version):

    [VB6] - Desktop lens.-VBForums

    i guess we need windowproc or maybe we need use SetWindowDisplayAffinity and WDA_EXCLUDEFROMCAPTURE (post 17) or any other way
    Last edited by Black_Storm; Jan 26th, 2023 at 02:58 AM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  21. #21
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: How to take a picture from the back of the form while the form is being displayed

    Well, then you seem to be in the (probable) right direction.
    You need to experiment with that API then.

    Code:
    Private Declare Function SetWindowDisplayAffinity Lib "user32" (ByVal hWnd As Long, ByVal dwAffinity As Long) As Long
    Private Const WDA_EXCLUDEFROMCAPTURE As Long = &H11&

  22. #22

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    if you could work with some apis or some tricks about this thread maybe you can help me (since you work on graphics and have experience with graphics in vb, you can definitely test solutions that may work.) , maybe can make a simple test about it, about that apis (in post 17) maybe these apis just work on special windows version for example just can work on windows 10(i am not sure,i just read in some websites about these apis work on special versions of windows,maybe its not work on win 7),i could not find any samples in vb about use these apis ,i am on windows 8 now. maybe you can check in higher windows if you use.
    Last edited by Black_Storm; Jan 26th, 2023 at 04:36 AM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  23. #23
    Addicted Member ISAWHIM's Avatar
    Join Date
    Jan 2023
    Posts
    181

    Re: How to take a picture from the back of the form while the form is being displayed

    Have you thought about just making a "child" form that is set to being "transparent"? If they have AERO being used, then use that... If NOT, then you fight with your custom roll-out version of transparency. (Also keeping in mind that some people ALSO have "transparency effects" disabled too.)

    If AERO and "transparency effects" are disabled for forms... Then you need a third option for displaying a capture area. A simple "preview window", which the user sets the "area", with a custom sizable form, is fine. You can make custom masked forms which have "holes" in them, so they are just a border. (That gives them the ability to move and resize it, if you leave a chunk in the center with something that can register a mouse-down, and mouse-move event, like a picturebox or just the raw form.)

    I disable form transparency, because, honestly, it is a waste of processing power in the OS. There is no need to see through a form, 99.99% of the time. Can't even think of a time when I wanted to "see through a form", which just makes that program harder to see. It was as dumb as windows making animations for opening and closing windows. Purely a novelty of, "We did it, because we could", not because anyone needed it. (Once they hijacked DX for the OS itself, to replace most of the GDI stuff, all this nonsense began.)

    Yes, I get that this is that 0.01% situation where it might be useful, but there are other viable alternatives. Don't go crazy looking for an impossible solution, to which there is none.

    The best possible, potential, solution... Would be to monitor EVERY displayed window, and track the windows positions, or try to hook some kind of callback to each window, to "know" when they have changed position or size. (Might seem virus-like doing the later.) Then, only once, you update the "blurred image", by hiding your program, getting a snapshot of that RECT where your program was, then use that as the new "blurry image". It's just one flicker, instead of many.

    When you want your program to do complex stuff, you have to program complex solutions. All the simple stuff has already been done and those things have simple solutions. (Like using AERO features, for those who use it.)

    Don't rule-out the simple, obvious, solution of a second child-form. Either as an attached body to the parent, moving with the form, or as a tiny "thumbnail" preview that can be moved out of the way or hidden, when it isn't needed. Think of Win-Amp, and the custom form shapes and "attached" child-forms to a parent.

  24. #24
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: How to take a picture from the back of the form while the form is being displayed

    Quote Originally Posted by Black_Storm View Post
    maybe these apis just work on special windows version for example just can work on windows 10(i am not sure,i just read in some websites about these apis work on special versions of windows
    You can read under Requirements:

    Minimum supported client: Windows 7 [desktop apps only]

  25. #25

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    i read these before too :
    what that means i did try for use google translator but not translated good ,maybe its make problem on win 7 or win 8 or its depened on some services should be run ?

    GetWindowDisplayAffinity function (winuser.h) - Win32 apps | Microsoft Learn

    This function and SetWindowDisplayAffinity are designed to support the window content protection feature unique to Windows 7. This feature enables applications to protect their own onscreen window content from being captured or copied via a specific set of public operating system features and APIs. However, it works only when the Desktop Window Manager (DWM) is composing the desktop.
    It is important to note that unlike a security feature or an implementation of Digital Rights Management (DRM), there is no guarantee that using SetWindowDisplayAffinity and GetWindowDisplayAffinity, and other necessary functions such as DwmIsCompositionEnabled, will strictly protect windowed content, as in the case where someone takes a photograph of the screen.

    SetWindowDisplayAffinity function (winuser.h) - Win32 apps | Microsoft Learn
    Starting in Windows 10 Version 2004, WDA_EXCLUDEFROMCAPTURE is a supported value. Setting the display affinity to WDA_EXCLUDEFROMCAPTURE on previous version of Windows will behave as if WDA_MONITOR is applied.
    Last edited by Black_Storm; Jan 26th, 2023 at 07:04 PM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  26. #26
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: How to take a picture from the back of the form while the form is being displayed

    In Windows 10+ you should not have any of these troubles, since DWM should be always running.

    Unfortunately these kind of things are not supported or too difficult to make them work on Windows 95/98/ME/NT4/2000/XP/7

  27. #27
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    439

    Re: How to take a picture from the back of the form while the form is being displayed

    Hello, I have tried many ways to do what you are looking for, but unfortunately from Windows 8 onwards it is no longer so easy or at least I still can't find the way, as you will see the example you are using of the magnifying glass works well in Windows 7 but not with later versions this is because it is no longer possible to capture behind ws_ex_layered windows
    however I haven't tried the SetWindowDisplayAffinity api when I have a while I'll see if this can help, it looks good.
    leandroascierto.com Visual Basic 6 projects

  28. #28
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,720

    Re: How to take a picture from the back of the form while the form is being displayed

    using the API
    https://learn.microsoft.com/en-us/wi...er-printwindow
    u can capture all windows, and after that its all about copy/cut around your window.

  29. #29

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    Quote Originally Posted by LeandroA View Post
    Hello, I have tried many ways to do what you are looking for, but unfortunately from Windows 8 onwards it is no longer so easy or at least I still can't find the way, as you will see the example you are using of the magnifying glass works well in Windows 7 but not with later versions this is because it is no longer possible to capture behind ws_ex_layered windows
    however I haven't tried the SetWindowDisplayAffinity api when I have a while I'll see if this can help, it looks good.

    if you can test for something about this thread on windows 8 too maybe it can be help.
    yes we can try more,maybe we can find good result.

    I tried the following method a few days ago, it shows the window in black in the captured image, I guessed that maybe the window is not in the image at all, but this function seems to only be black


    Code:
    ' REF : https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowdisplayaffinity
    
    
    
    
    Private Declare Function SetWindowDisplayAffinity Lib "user32" (ByVal hWnd As Long, ByVal dwAffinity As Long) As Long
    Private Declare Function GetWindowDisplayAffinity Lib "user32" (ByVal hWnd As Long, dwAffinity As Long) As Long
    
    'Imposes no restrictions on where the window can be displayed.
    WDA_NONE
    
    
    'The window content is displayed only on a monitor. Everywhere else, the window appears with no content.
    WDA_MONITOR
    
    
    'he window is displayed only on a monitor. Everywhere else, the window does not appear at all.
    'One use for this affinity is for windows that show video recording controls, so that the controls are not included in the capture.
    'Introduced in Windows 10 Version 2004. See remarks about compatibility regarding previous versions of Windows.
    WDA_EXCLUDEFROMCAPTURE
    
    
    Private Const WDA_NONE As Long = &H0&
    Private Const WDA_EXCLUDEFROMCAPTURE As Long = &H11&
    Private Const WDA_MONITOR As Long = &H1&
    
    Private Sub Command5_Click()
    SetWindowDisplayAffinity hWnd, WDA_EXCLUDEFROMCAPTURE 
    Dim c As Long
    MsgBox GetWindowDisplayAffinity(hWnd, c)
    MsgBox c
    SetWindowDisplayAffinity hWnd, WDA_NONE 
    MsgBox GetWindowDisplayAffinity(hWnd, c)
    MsgBox c
    End Sub
    result is like as :
    c# - How to use SetWindowDisplayAffinity - Stack Overflow


    this itself creates another problem when there are forms behind our program and it cannot get their content if we want to use this function in the case that we want to take a picture of the whole page with the help of this function.
    Last edited by Black_Storm; Jan 28th, 2023 at 05:38 AM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  30. #30

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    Quote Originally Posted by baka View Post
    using the API
    https://learn.microsoft.com/en-us/wi...er-printwindow
    u can capture all windows, and after that its all about copy/cut around your window.

    did u see this :
    https://www.vbforums.com/showthread....ide-of-desktop
    its about using printwindow to i solved some problems(i had to move my window (layered canvas not like as standard form vb) outside of desktop to i can take image from it and used printwindow for solve) but it have some problem for use about this thread here.

    if you know you can do make something with using printwindow and about this thread you can try for test.if you find good result you can show here.


    I had used the same method temporarily in post number 1 from the beginning, but the form is blinking and its need live render. Meanwhile, read the description of the posts. The problem now is more than this, when the form is on the page and the user can move the windows under the program or A change is made under the form of the program that must be rendered in the program at the same moment, the problem in your explanation is that if there are windows below the window, they will be destroyed by cutting the lower windows.


    In my opinion, for now, the only ways are either to process all the activities with the help of windowproc, or all the windows should be drawn on one DC, that is, the content of each window should be obtained separately, and all the drawings except the my window It is desirable to draw a DC, which is not an easy task and has some problems.
    Last edited by Black_Storm; Jan 28th, 2023 at 05:30 AM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  31. #31
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,720

    Re: How to take a picture from the back of the form while the form is being displayed

    if the backgrounds are animated, it will be harder to achieve.
    but if u instead ignore that u can just create a memory dc of the background.
    this u do when your form gets focus. u just need to hide your form when u are doing a screenshot of the desktop.
    so u are not continuously taking a screenshot, just when your form is getting focus.

    another solution.
    u use a transparent color where u want to show that blurry background.
    now u will always see the background. now, using another form, u cover that part that will create that blurry picture of the background. at least its just a small area that u do that not the entire form.

  32. #32
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: How to take a picture from the back of the form while the form is being displayed

    Code:
    Private Declare Function GetWindowDisplayAffinity Lib "user32" (ByVal hWnd As Long, ByRef dwAffinity As Long) As Long
    
    [...]
    
    If GetWindowDisplayAffinity(hWnd, c) then MsgBox c

  33. #33

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    Quote Originally Posted by Eduardo- View Post
    Code:
    Private Declare Function GetWindowDisplayAffinity Lib "user32" (ByVal hWnd As Long, ByRef dwAffinity As Long) As Long
    
    [...]
    
    If GetWindowDisplayAffinity(hWnd, c) then MsgBox c
    I had forgotten to put the function in the modified form in the old code, I had used the following form in the project, which was not a problem.

    Code:
    Private Declare Function GetWindowDisplayAffinity Lib "user32" (ByVal hWnd As Long, dwAffinity As Long) As Long
    seems these apis cant help about this thread,i am not sure yet.
    Last edited by Black_Storm; Jan 28th, 2023 at 05:40 AM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  34. #34
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: How to take a picture from the back of the form while the form is being displayed

    ByRef and omitting it are the same since ByRef is the default.

  35. #35

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    yes i know, i guess i just to be focus on draw all windows on one dc without my wanted window but i guess still its hard special when my window is layered canvas too.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  36. #36
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,720

    Re: How to take a picture from the back of the form while the form is being displayed

    I wouldn't do that.
    I would just take a screenshot of the desktop, hiding the form, its just milliseconds.
    after that I use the memoryDC to create the blurry picture.
    also, the .gif/preview u show. it seems to use the lock/release version when u move around the form.
    I dont like that method at all. but its up to u.

  37. #37

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: How to take a picture from the back of the form while the form is being displayed

    Quote Originally Posted by baka View Post
    if the backgrounds are animated, it will be harder to achieve.
    but if u instead ignore that u can just create a memory dc of the background.
    this u do when your form gets focus. u just need to hide your form when u are doing a screenshot of the desktop.
    so u are not continuously taking a screenshot, just when your form is getting focus.

    another solution.
    u use a transparent color where u want to show that blurry background.
    now u will always see the background. now, using another form, u cover that part that will create that blurry picture of the background. at least its just a small area that u do that not the entire form.
    read post 1 and 18,its need render alive to can keep all changes alive in behind form and hide form is not good idea as i used in post 1 , u can see result in post 1 about flicker problem when user wanna move form or some changes maybe available beind window (animation is not only means ,means like as more than this like as all windows behind window can change position or another changes in live time.

    see this link about a simple problem to will be happen too in my post 2 in this link and will be happen here about this thread too :
    [VB6] - Desktop lens.-VBForums


    baka It can always seem simple to say in theory and present the solution, but when you want to design and then implement, you will see what problems will arise.
    just make a test about your solutions when u had time.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  38. #38
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,720

    Re: How to take a picture from the back of the form while the form is being displayed

    if its real-time, why not just use a filter
    create a semi-transparent form with a "blurry-filter".

    1. a rectangle semi-transparent with a filter-picture
    2. a form where u use solid-fully-transparent color.

    I mean, all this copy/paste is just too much work.

  39. #39
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    439

    Re: How to take a picture from the back of the form while the form is being displayed

    Definitely that SetWindowDisplayAffinity does what I wanted, but the final result is not good, it is very far from DwmExtendFrameIntoClientArea or SetWindowCompositionAttribute, the problem of trying to keep what goes behind the form in real time has its cost and it does not refresh like the apis mentioned above.
    I show this example, without applying a blur it only shows the back part of the form in real time (if your dpi is different from 100, you would have to factor and reduce the capture. StretchBlt)

    Code:
    Option Explicit
    Private Declare Function GetDC Lib "user32.dll" (ByVal hwnd As Long) As Long
    Private Declare Function BitBlt Lib "gdi32.dll" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Private Declare Function ReleaseDC Lib "user32.dll" (ByVal hwnd As Long, ByVal hdc As Long) As Long
    Private Declare Function GetClientRect Lib "user32.dll" (ByVal hwnd As Long, ByRef lpRect As RECT) As Long
    Private Declare Function ClientToScreen Lib "user32.dll" (ByVal hwnd As Long, ByRef lpPoint As POINTAPI) As Long
    'Private Declare Function StretchBlt Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
    'Private Declare Function SetStretchBltMode Lib "gdi32.dll" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long
    Private Declare Function SetWindowDisplayAffinity Lib "user32" (ByVal hwnd As Long, ByVal dwAffinity As Long) As Long
    Private Const WDA_EXCLUDEFROMCAPTURE As Long = &H11&
    
    Private Type POINTAPI
        x As Long
        y As Long
    End Type
    
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    
    Private Sub Form_Load()
        SetWindowDisplayAffinity hwnd, WDA_EXCLUDEFROMCAPTURE
        Me.AutoRedraw = True
        Timer1.Interval = 1
    End Sub
    
    Private Sub Timer1_Timer()
        Dim R As RECT, DC As Long, PT As POINTAPI
        GetClientRect hwnd, R
        ClientToScreen hwnd, PT
        DC = GetDC(0)
        BitBlt hdc, 0, 0, R.Right - R.Left, R.Bottom - R.Top, DC, PT.x, PT.y, vbSrcCopy
        ReleaseDC 0, DC
        Me.Refresh
    End Sub
    leandroascierto.com Visual Basic 6 projects

  40. #40
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,720

    Re: How to take a picture from the back of the form while the form is being displayed

    timer is not reliable. it need to be subclassed or using a loop.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width