Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › WinApi - Double buffering Window + Controls, background glitch
New Posts  All Forums:Forum Nav:

WinApi - Double buffering Window + Controls, background glitch

post #1 of 2
Thread Starter 
Hey guys, I'm helping a friend with come scada like program, he's doing some electronic stuff and needs an interface using serial port to show/update some images (fluid level). I'll say its 99% done, but as title says I've got a glitch with my windows background.

The window I'm creating is WS_EX_COMPOSITED so the controls (only 4, 2 static, 1 button, 1 list) have doublebuffering (afaik, and it works from what I can tell). I'm using PeekMessage for my main loop instead of the regular GetMessage because we need it to do/show stuff without user input. Inside my main loop I'm handling the Draw() function. My controls are drawn during WM_CREATE and their contents updated accordingly in my Draw() function. My WM_ERASEBKGND return TRUE.

Now, the problem is; although I have this on my window class
Code:
wcMain.hbrBackground= (HBRUSH)GetStockObject(XXXX_BRUSH);

And this to delete my background before repainting to avoid flickering
Code:
backgroundBrush = CreateSolidBrush(GetSysColor(XXXX_BRUSH));
FillRect(hdcMem, &rc, backgroundBrush);
DeleteObject(backgroundBrush);
SetBkMode(hdcMem, TRANSPARENT);

My window shows some weird background, if I put BLACK_BRUSH everything inside the first and last control is filled with a light gray-ish color. If I put LTGRAY_BRUSH my background is all black. There is no difference is I use OPAQUE in SetBkMode.

Here is the window If I have BLACK_BRUSH, notice the black border around, I noticed If i move the top-left control (STATIC) the border kind of grow to the next control, is like the black background surrounds the outer controls(top of the static, left and right of the listbox and bottom of the button) or something like that.
700

Thanks in advance.
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
post #2 of 2
Thread Starter 
Well I decided to rewrite it using SDL lol. Doesn't do that weird background thing but it feels a little slower. Just need to fix that and I'm done. In short: don't use GDI+ !!!
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › WinApi - Double buffering Window + Controls, background glitch