<div dir="ltr">Hi folks,<div> I setup VS2008 Cairo hello world project without using GTK+ for windows.</div><div><br></div><div>Actually Cairo has win32 surface support(base on GDI). Use cairo_win32_surface_create </div>
<div><br></div><div>instead of other surface creating API (like <span class="Apple-style-span" style="border-collapse: collapse; ">cairo_image_surface_create<span class="Apple-style-span" style="border-collapse: separate; ">).</span></span></div>
<div><br></div><div>Only few instructions need to be follow:</div><div>0. Download cairo lib for windows.</div><div>1. Use wizard to create a win32 project in Visual C++ 2008 express. </div><div>2. Open <your project name>.cpp and find function WndProc.</div>
<div>3. Modify WM_PAINT branch with piece of code below:</div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>case WM_PAINT:</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>hdc = BeginPaint(hWnd, &ps);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>// TODO: Add any drawing code here...</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>cairo_surface_t *surface;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>cairo_t *cr;</div>
<div><br></div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>surface = cairo_win32_surface_create(hdc);</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>cr = cairo_create(surface);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>Draw(cr); // <<<<<<Cairo draw here</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>cairo_destroy(cr);</div><div>
<span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>EndPaint(hWnd, &ps);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>break;</div>
</div><div>4. Add cairo lib path to new project.</div><div>5.Compile and check the result</div><div><br></div><div>After that, you will see your cairo drawing in Windows program's client area.</div><div><br></div><div>
Hope it is helpful, and correct me if there are mistakes.</div><div><br><br><div class="gmail_quote">2008/9/2 Mohit Sindhwani <span dir="ltr"><<a href="mailto:tech@onghu.com">tech@onghu.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">Asko Kauppi wrote:<br>
> I would second this.<br>
><br>
> Although setting up a "Hello world" IDE project drawing the text using<br>
> Cairo should not be a Big Deal, it certainly would help the initial<br>
> step (instead of pressing 'new' in the IDE).<br>
><br>
> Especially since Windows is my 3rd platform, and I am using VC++ 2008<br>
> Express only occasionally. So, if anyone has a "Hello world" Cairo +<br>
> VC++ 2008 project to spare, thanks! :)<br>
><br>
> In fact, I would like to see such Hello World for VC++, GTK+ and OS X<br>
> (XCode) all of them.<br>
><br>
> -asko<br>
><br>
</div>Actually I have a Hello World example for Borland Turbo C++ (the new<br>
currently free version of C++ Builder) - I'm a bit busy the next few<br>
days, but should be able to post more information about it in the weekend.<br>
<br>
Cheers,<br>
Mohit.<br>
9/2/2008 | 12:24 AM.<br>
<div><div></div><div class="Wj3C7c"><br>
_______________________________________________<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a><br>
</div></div></blockquote></div><br></div></div>