[Question] GDI+  Clear() function menu

User Tag List

Results 1 to 7 of 7
  1. #1
    DrakeFish's Avatar Lazy Leecher

    Reputation
    634
    Join Date
    Nov 2008
    Posts
    569
    Thanks G/R
    0/14
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Question] GDI+ Clear() function

    I successfully made a transparent window where I want to draw using GDI+ in C#. The problem is that when I call the Clear function, even with "Colors.Transparent", it fills the window with some color... My hint is to draw on top of the other window behind mine, and I couldn't find something that really only clear the screen, without filling it with a colour, yet. Anyone has an idea?

    If this isn't possible in GDI+, would it be possible in DirectX 2D ?
    Last edited by DrakeFish; 08-08-2010 at 12:44 PM.

    [Question] GDI+  Clear() function
  2. #2
    suicidity's Avatar Contributor
    Reputation
    207
    Join Date
    Oct 2006
    Posts
    1,439
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    ...
    {
    	SetWindowLong(this.Handle, -20, (IntPtr)(GetWindowLong(this.Handle, -20) ^ 0x80000 ^ 0x20));
    	SetLayeredWindowAttributes(this.Handle, 0, 255, 0x2);
    }
    
    [DllImport("user32.dll")]
    int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
    [DllImport("user32.dll")]
    bool SetLayeredWindowAttributes(IntPtr hWnd, uint crKey, byte bAlpha, uint dwFlags);
    Small anti-copypasta, But you should figure it out.


  3. #3
    DrakeFish's Avatar Lazy Leecher

    Reputation
    634
    Join Date
    Nov 2008
    Posts
    569
    Thanks G/R
    0/14
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found out how, i don't know why I didn't think about it but I've set my Form Transparency Key to Lime, and then used Clear(Color.Lime), the only problem is that it flickers way too much, so I will try using D3D and see if I get better results.

  4. #4
    suicidity's Avatar Contributor
    Reputation
    207
    Join Date
    Oct 2006
    Posts
    1,439
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's a cheesy way of doing it, and results in terrible stuff; Do what I recommended and you'll be fine.


  5. #5
    DrakeFish's Avatar Lazy Leecher

    Reputation
    634
    Join Date
    Nov 2008
    Posts
    569
    Thanks G/R
    0/14
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by suicidity View Post
    Code:
    ...
    {
    	SetWindowLong(this.Handle, -20, (IntPtr)(GetWindowLong(this.Handle, -20) ^ 0x80000 ^ 0x20));
    	SetLayeredWindowAttributes(this.Handle, 0, 255, 0x2);
    }
    
    [DllImport("user32.dll")]
    int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
    [DllImport("user32.dll")]
    bool SetLayeredWindowAttributes(IntPtr hWnd, uint crKey, byte bAlpha, uint dwFlags);
    Small anti-copypasta, But you should figure it out.
    What does that do exactly, I am looking for something that will make the window flicker less when using Clear, or something to replace the Clear. I don't get when in the script I'm supposed to use those 2 lines.
    Last edited by DrakeFish; 08-08-2010 at 04:25 PM.

  6. #6
    suicidity's Avatar Contributor
    Reputation
    207
    Join Date
    Oct 2006
    Posts
    1,439
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Helping you is pointless.. But as you already have the solution, have fun trying to copy paste it.


  7. #7
    DrakeFish's Avatar Lazy Leecher

    Reputation
    634
    Join Date
    Nov 2008
    Posts
    569
    Thanks G/R
    0/14
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found my solution by using DirectX, which is 100x better since there's no flicker at all, which is what i wanted.
    Also, thanks for the tip on using SetLayeredWindowAttributes.

Similar Threads

  1. Question about boost::function
    By GliderPro in forum Programming
    Replies: 2
    Last Post: 01-24-2010, 09:08 AM
  2. noob question - call method function
    By ostapus in forum WoW Memory Editing
    Replies: 5
    Last Post: 11-09-2009, 09:10 PM
  3. Question: LUA Functions Restricted to Hardware Events
    By jagged software in forum WoW Memory Editing
    Replies: 3
    Last Post: 03-28-2009, 01:59 PM
  4. [Question] Lua functions
    By Lich King in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 04-10-2008, 07:39 PM
  5. [Emulator Question] WoW Pets Functioning Correctly
    By TrunksVegita in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 01-13-2008, 02:05 AM
All times are GMT -5. The time now is 09:47 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search