Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - Window DCs getting mixed up, or something... | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4908/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 06-11-05 09:11 AM Link | Quote
Image (102K, 546x586)

If you can pull your eyes away from my desktop long enough you'll notice a small inconsitency in the numbering of these 10 pink squares, each of which is a window. For some reason which seems to defy all logic, the code that numbers them is simply skipping this window, no matter how many I create (though less than that works fine); drawing a black spot but no number, and somehow not even incrementing the number.

First I register a default window class:
//Create a default window class
sprintf(WindowClassName,"DESKTOP_GADGETS");

WindowClass.cbSize = sizeof(WNDCLASSEX); //Struct size (don't fuck with)
WindowClass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; //Style flags
WindowClass.lpfnWndProc = ProcMessage; //Message handler
WindowClass.cbClsExtra = 0; //Extra junk
WindowClass.cbWndExtra = 0; //Extra junk
WindowClass.hInstance = hInst; //Program handle (don't fuck with)
WindowClass.hIcon = LoadIcon(NULL, IDI_WINLOGO); //Default icon
WindowClass.hCursor = LoadCursor(NULL, IDC_ARROW); //Default cursor
WindowClass.hbrBackground = WindowBrush; //Default brush
WindowClass.lpszMenuName = NULL; //No menu
WindowClass.lpszClassName = WindowClassName; //Class name
WindowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO); //Taskbar icon

//Register the window
if(!RegisterClassEx(&WindowClass)) Die("RegisterClassEx() failed" LINENUM);
DebugOut(DO_ALL,"Registered default window class\n");


Then create 10 windows using it:
int q;
for(q=0;q<10;q++)
{
NewWindow(-1,-1,NULL,50,q*60,50,50,"Test");
DrawString(WindowInfo[q].hDC,20,20,false,"%d",q);
//Sleep(500);
ProcessMessages();
}
void ProcessMessages()
{
MSG msgMessage; //Window message
for(CurrentWindow=0;CurrentWindow<NumWindows;CurrentWindow++)
{
if(PeekMessage(&msgMessage,WindowInfo[CurrentWindow].hWnd,0,0,PM_REMOVE))
{
//Yes, send it off
TranslateMessage(&msgMessage);
DispatchMessage(&msgMessage);
}
if(WindowInfo[CurrentWindow].IsMoving)
{
GetCursorPos(&point);
rect.left = point.x - WindowInfo[CurrentWindow].MouseOffset.x;
rect.top = point.y - WindowInfo[CurrentWindow].MouseOffset.y;
Window_SetPos(WindowInfo[CurrentWindow].hWnd,rect.left,rect.top);
}
}
}

HWND NewWindow(DWORD Style,DWORD ExStyle,HBRUSH BGBrush,int x, int y, int w, int h, char* Title)
{
if(NumWindows >= sizeof(WindowInfo))
{
DebugOut(DO_MINOR,"Cannot create any more windows\n");
return 0;
}

DWORD e,s;
if(Style == -1) s = (WS_CHILD | WS_POPUP | WS_VISIBLE); else s = Style;
if(ExStyle == -1) e = 0; else e = ExStyle;

//Create the window
WindowInfo[NumWindows].hWnd = CreateWindowEx(
e, /* Extended styles*/
"DESKTOP_GADGETS", /* Class name again */
Title, /* Title */
s, /* Window style flags */
x, y, w, h, /* Position and size */
hDesktop, /* Parent window handle (desktop) */
NULL, /* Menu handle (none) */
hInst, /* Program handle (don't fuck with) */
NULL); /* Parameter */

WindowInfo[NumWindows].hDC = GetDC(WindowInfo[NumWindows].hWnd);
DebugOut(DO_STATUS,"Created window '%s' (#%d); hWnd=0x%08X, hDC=0x%08X\n",
Title,
NumWindows,
WindowInfo[NumWindows].hWnd,
WindowInfo[NumWindows].hDC);
NumWindows++;
}



DrawString() simply processes the string and draws it on a given DC. Somehow, though, this specific window is getting skipped.
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Programming - Window DCs getting mixed up, or something... | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.004 seconds.