不,我自己没有解决这个问题。我可能在错误的地方询问了后续问题。 我不确定如何提出跟进问题。WinAPI in C. Please no C++!!I am using this stolen code:(part shown only, nice small plain C)// create the main windowWind[0] = CreateWindowEx( WS_EX_CONTROLPARENT, "TINY_UNICODE","Tiny Unicode Editor", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,0,500,300,NULL,NULL,Inst,NULL);// buttonsWind[1] = CreateWindow("BUTTON","Open", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 2,2,50,25,Wind[0],(HMENU) 1001,Inst,NULL);Wind[2] = CreateWindow("BUTTON","Save", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 2,30,50,25,Wind[0],(HMENU) 1002,Inst,NULL);Wind[3] = CreateWindow("BUTTON","Quit", WS_CHILD | WS_VISIBLE | BS_FLAT, 2,60,50,25,Wind[0],(HMENU) 1003,Inst,NULL);// edit windowWind[4] = CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT",NULL, WS_CHILD | WS_VISIBLE | ES_MULTILINE, 60,2,200,200,Wind[0],NULL,Inst,NULL);Now I want to replace the edit control Wind[4] with a static control to draw graphs using SetPixel(hdc, x, y, z, 0, 0));For that I need to get the hdc of the window Wind[4].Please how do I do that?Thank youJohan SmitNo I have not solved this myself. I probably asked the follow-up question on the wrong place.I am unsure how to place follow up questions.推荐答案 参见 GetDC() [ ^ ]。 请务必致电 ReleaseDC() [ ^ ]完成后使用它。 / ravi See GetDC()[^].  Be sure to call ReleaseDC()[^] when done using it./ravi 在绘制窗口之前我建议你阅读GDI以了解windows图形界面,否则你会迷路... 加速此处您可以找到文档。仔细研究它,你就会得到你想要的解决方案。 无论如何,这是一个在窗口上绘制正弦线的简单代码: Before drawing in a window I suggest you to read about GDI to have a good understanding of windows graphical interface, or you'll get lost...To speed here you'll find documentation. Study it carefully and you'll get the solution you are looking for.Anyway this is a simple code to draw a sinus line on a window:void GraphSomething(HWND hwnd){RECT rWin;GetClientRect(hwnd, &rWin);//Get window dimensionsHDC hDc = GetDC(hwnd);HPEN hPen = CreatePen(PS_DASHDOT, 2, RGB(255, 0, 0));HPEN hOldPen = SelectObject(hDc, hPen);float f = 4.0*3.14 / (float)(rWin.right-rWin.left);MoveToEx(hDc, rWin.left, rWin.bottom/2 - ((float)rWin.bottom/2 * sin(0.0)), NULL);for (int i=rWin.left; i<rWin.right; i++){int pt = (float)rWin.bottom/2 * sin(f * (float)(i));LineTo(hDc, i, rWin.bottom/2 - pt);}DeleteObject(SelectObject(hDc, hOldPen));ReleaseDC(hwnd, hDc);} 谢谢Ravi。 我不懂GetDC [^] 当我做GetDC(Wind [4])我在Pelles C调试器中得到结构HDC_ * hdc = struct HDC_ = int unused *< f701644?> ,并且像素不是设置在任何地方。Thank you Ravi.I don't understand GetDC[^]When I do GetDC(Wind[4]) I get struct HDC_*hdc = struct HDC_ = int unused *<f701644?>in the Pelles C debugger, and the pixel are not set anywhere. 这篇关于如何获得Wind [4]的hdc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-26 02:48