   Handles and HDC in Win32...
  I''ve just started learning Win32 api and I don''t fully understand the HDC concept...First of all, Device context is a structure containing variables defying an object (According to some definition), I''m not sure if I get it right...I''ve been programming in C++ Builder so can I call all the TLabel, TButton, TEditBox and TForm DC? They''re structures which contain variables which tell you about the object itself... am I correct...Second, I don''t get the use of the HWND handle and the HDC one...for example you have to paint the box you need to use HWND:BeginPaint(hwnd, &paintStruct);but to print a text on it you use HDCTextOut(hdc,TEXT_X,TEXT_Y,text,strlen(text));(generally it seams you use HDC for text stuff:GetTextMetrics(hdc, &textInfo)SetTextColor(hdc, RGB(255, 0, 0)))Also to get Client RECT you must use HWND:GetClientRect(hwnd,▭);but to fill it, HDC:FillRect(hdc,&rect,(HBRUSH)GetStockObject(WHITE_BRUSH));Am I missing something here or does it simply make no sense??Also, what does begin and endpaint do? I''ve deleted it from my program and it still works the same... also, what does the PAINSTRUCT really hold (when starting paint)?Thanks in advance... 
  You''re right.  It''s weird.  You can look up all of the structure elements and function parameters at msdn.microsoft.com. From there you should do a search in the library. ;  I don''t understand it all either... I just go with the flow, and hopefully, just like the rest of the stuff I learned... it will just come to you one day.Other than that, just read books... tutorials, and any other resources available to you. ;  eeek! This is a long question.In the context of your question an HDC is an handle to an graphic device structure. A graphic device structure is just an structure containing information on the graphic card installed on your system as well as the drawing surface -  the window, the Pen (used to draw lines) and the Brush (used to fill objects. This information is needed by windows to display graphics properly whenever you make a call to the GDI.About TLabel, TButton etc. Windows is an object orientated operating system and Buttons, Labels exist within windows as a Class or object. To create one with pure code you would use the CreateWindowEx() api call and pass in "button" as the class type to create. It may seem strange to use CreateWindowEx to create a control but windows,buttons,labels are just classes to windows.Understanding how WM_PAINT works is very important because most window programs revolve around this message. The WM_PAINT message (or event, if you prefer) is sent to your program whenever your window needs to repaint itself(window got moved, minimised etc).Now a HWND is just a varible that identifies what window we are dealing with. When a window is first created with CreateWindowEx  , the function returns a HWND value that unquies identifies that window.BeginPaint(hwnd, &paintStruct);It is nesscary to use hwnd in the call to BeginPaint because beginpaint can paint in any window in your application. BeginPaint also returns a HDC or graphics context which describes the video system and drawing surface of your system.HDC hdc = BeginPant(hwnd, &paintStruct);In a nutshell you need the HDC when doing graphics because it describes your graphic card as well as a few parameters detailing how to draw such as what colour to draw in etcFillRect(hdc,&rect,(HBRUSH)GetStockObject(WHITE_BRUSH));This call should now make a little more sence. You need the hdc to draw on anything in windows, the rect is just telling FillRect the co ordinates you want to fill.BeginPaint and EndPaint simply validates the client rectangle of your window. If you dont handle it, then windows will do it for you which your program still worked when you deleted it. I really need an entire chapter of a book to explain this to you properly but I hope that helps a little.Basically HWND is just a pointer to a structure that contains information on a window such as its width, height, location, color etc. An HDC contains information on the surface of your window as well as your graphic card so it needed by window functions for drawing.You can get the HDC of any window with HDC hdc = GetDC(hwnd); 