Groups | Search | Server Info | Login | Register
Groups > comp.os.ms-windows.programmer.misc > #24
| X-Received | by 10.224.57.65 with SMTP id b1mr1346922qah.2.1371362154274; Sat, 15 Jun 2013 22:55:54 -0700 (PDT) |
|---|---|
| X-Received | by 10.49.24.208 with SMTP id w16mr260464qef.37.1371362154239; Sat, 15 Jun 2013 22:55:54 -0700 (PDT) |
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!bw2no1851673qab.0!news-out.google.com!y6ni2993qax.0!nntp.google.com!j2no352849qak.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.os.ms-windows.programmer.misc |
| Date | Sat, 15 Jun 2013 22:55:54 -0700 (PDT) |
| In-Reply-To | <d0bc4f37-5302-496a-aab1-088c75262034@googlegroups.com> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=2.177.114.176; posting-account=qc51SAoAAAASmnHqyXwbmcAUkjDP4HPo |
| NNTP-Posting-Host | 2.177.114.176 |
| References | <d0bc4f37-5302-496a-aab1-088c75262034@googlegroups.com> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <0eac2ee9-502e-49c2-878c-77fe9103c46f@googlegroups.com> (permalink) |
| Subject | Re: Simplest possible C win32 app to draw line? |
| From | moosavi78@gmail.com |
| Injection-Date | Sun, 16 Jun 2013 05:55:54 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Xref | csiph.com comp.os.ms-windows.programmer.misc:24 |
Show key headers only | View raw
On Sunday, June 17, 2012 1:33:51 AM UTC+4:30, Dan Kegel wrote:
> What is the absolute simplest win32 program that draws a line in a window?
>
>
>
> I tried
>
>
>
> #include <windows.h>
>
> int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpCmdLine, int nShowCmd)
>
> {
>
> MSG msg;
>
> HWND hwnd;
>
> HDC hdc;
>
> RECT rect;
>
> WNDCLASS wc;
>
>
>
> ZeroMemory(&wc, sizeof(wc));
>
> wc.lpfnWndProc = DefWindowProc;
>
> wc.hInstance = hinst;
>
> wc.hCursor = LoadCursor(NULL, IDC_ARROW);
>
> wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
>
> wc.lpszClassName = "Foobar";
>
> RegisterClass(&wc);
>
> hwnd = CreateWindow(
>
> "Foobar",
>
> "Foobar",
>
> WS_OVERLAPPEDWINDOW,
>
> CW_USEDEFAULT, CW_USEDEFAULT,
>
> 512, 512,
>
> NULL,
>
> NULL,
>
> hinst,
>
> 0);
>
> hdc = GetDC(hwnd);
>
> GetClientRect(hwnd, &rect);
>
> FillRect(hdc, &rect, (HBRUSH) (COLOR_WINDOW+1));
>
> MoveToEx(hdc, 100, 100, NULL);
>
> LineTo(hdc, 200, 200);
>
> ReleaseDC(hwnd, hdc);
>
> ShowWindow(hwnd, nShowCmd);
>
> Sleep(5000);
>
> return 0;
>
> }
>
>
>
> but the window was not shown. Is the problem that I
>
> don't have a window proc? I was hoping I could just
>
> draw immediately without having to use the event system.
>
>
>
> Thanks,
>
> Dan
Try all those codes in a WP_PAINT message and create hdc with BeginPaint and Release HDC with EndPaint . this should work !
Back to comp.os.ms-windows.programmer.misc | Previous | Next — Previous in thread | Find similar
Simplest possible C win32 app to draw line? Dan Kegel <daniel.r.kegel@gmail.com> - 2012-06-16 14:03 -0700 Re: Simplest possible C win32 app to draw line? moosavi78@gmail.com - 2013-06-15 22:55 -0700
csiph-web