Rendering a custom owner-drawn button in Runtime

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hey there,

    So I am working on a custom owner-drawn button in the Win32 runtime. I have a RenderTo() function that I created which renders the button the way I want it to appear.

    The RenderTo function has this signature:

    Code
    void RenderTo(LPSURFACE ps, mv _far* mV, RECT FAR* rc, HFONT hFont, COLORREF dwBackColor, 
    COLORREF dwTextColor, TCHAR *sFilename, DWORD dwAlignFlags, TCHAR* wText);

    It works correctly in the Edittime.cpp when called like so:

    So I am trying to call the same drawing function from the Runtime.cpp file but can't figure out why it isn't working correctly and can't really find much in the way of documentation for this.

    Here's one attempt, using the owner drawn Win32 message (in WindowProc):

    The code is being called but all I get is a blank white rectangle where the control should be (but this does not seem to come from any of my drawing code).

    I also tried to call RenderTo() from DisplayRunObject:

    (I return REFLAG_DISPLAY from HandleRunObject() so this is getting called). But again, nothing actually shows up.

    Any ideas how I can get this to work?

  • Replacing my draw code in Runtime with the example from the help file doesn't even seem to work (I moved the child window so it wouldn't cover anything up):

    Just a blank window with the background color of the Frame:

    Please login to see this attachment.

  • The default runtime of Fusion these days is Direct3D (9 or 11) which does not implement the majority of cSurface drawing routines for hardware-accelerated surfaces. If not even the simple SDK example works, I assume that you are using the hardware-accelerated runtime, in which case I suggest setting the display mode to "Standard" in the application settings and see if that works. To render onto the screen in Direct3D, you can call Blit() onto it from a texture Surface, see Please login to see this link. for how to create a texture from a bitmap Surface.

    Please login to see this link.

  • Ah, yes of course, that was the problem with the basic SDK example. I got something appearing on the screen finally.

    So the next issue is if it's possible to do something like WinGetSurface with a child window? I want the control to be able to have keyboard focus, etc. so it makes the most sense to make it an owner drawn object and let Windows continue to do all that stuff. I wasn't able to find anything that would obviously take a HWND and return a cSurface however. Is there a way to do this or do I need to rewrite my drawing code to use plain Win32 at runtime in this case?

    Or maybe a way to blit from a cSurface directly to a HWND's drawing context? WM_DRAWITEM sets up a dc for you, so if there's a way to get a DIB from the cSurface I can just blit that to the child form I think.

    Again thanks for the help!

  • Ah and I just found some code in the help file that does actually do something like what I want, so I have something showing up in the child window now.

    Now just to figure out why it can't load the image at runtime...

    Make sure you request the image filters, maybe look into EnumElts in help file too.
    Be aware any text-drawing extensions in Unicode mode will need their Unicode text passed as unsigned short *, not wchar_t *, due to an old compatibility issue.

    Darkwire Software Lead Programmer (C++ & C#)
    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

  • Yeah storing the images in the image bank and using EnumElts ended up being better way to go since the images are stored in the produced app. I'm still a little puzzled why the external PNG load didn't work even though it works in the editor.

    You could refer to Please login to see this link. to see how it does it :)

    Darkwire Software Lead Programmer (C++ & C#)
    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!