CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2002
    Posts
    14

    custom controls with win32api

    hello....
    i want to know, if there is a way for me to create a costum control on a dialog only using win32api, without using MFC.

    i have a dialog, and on it, there is a part i have to interact with (its supposed to be a table of pictures, and the user is supposed to click on one of them, and it then have to changes, etc, etc...)

    i know that the best tool for me to do exactly what i want with MFC would be a costum control...
    but i havn't found a single reffernce to how to do costum controls with win32api and without MFC in any book or site.

  2. #2
    Join Date
    Mar 2002
    Posts
    12

    Custom controls using Win32

    Here are some ideas on how to create custom controls using Win32 only.

    1. Since all controls are windows, you can create a new window using CreateWindowEx(...), with given attributes, color, style and size. You'll have to register a new class for that window and create a Window Procedure. Within window procedures you can catch such messages as WM_LBUTTONDOWN, WM_LBUTTONDBLCLK, to handle messages from your control. In fact, you can use wizard to create a Win32 Applcation. It will create a window, code to register a new class for it and window procedure. This is the most "right" way to create a custom control.

    2. You can display a image (bitmap) on your Dialog and then "catch" messages, (like WM_LBUTTONDOWN, WM_MOUSEMOVE, and so on) on your WndDialog procedure (see the 4-th parameter of CreateDialog()), and then check mouse coordinates to detect where event occured. For example, if event occured on an immage, which is supposed to be a button and that event is WM_LBUTTONDOWN, you may want to replace the image to create the "button pressed" effect.

    Hope this will help.
    Regards,
    Dinu.

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: custom controls with win32api

    To add to dinus's explanation, you may need to register the window class as CS_GLOBALCLASS.
    Originally posted by cyberia_2ooo
    hello....
    i want to know, if there is a way for me to create a costum control on a dialog only using win32api, without using MFC.
    Yes. Custom controls existed before there was an MFC. MFC is for the most part, a wrapper around the Windows API.
    but i havn't found a single reffernce to how to do costum controls with win32api and without MFC in any book or site.
    A book that was available was "Windows 95: A Developers Guide" by Jeffrey Richter. It contained an entire chapter on creating custom controls. I'm sure whatever applies to Windows 95 should for the most part, apply to any 32-bit Windows OS when it comes to creating custom dialog controls.

    Regards,

    Paul McKenzie

  4. #4
    Join Date
    Jul 2003
    Location
    Korea
    Posts
    60
    I know a FFT program written by Relisoft company (http://www.relisoft.com). Its source code is public. All program uses win32 API functions, and the program has good interface. Let's try it.
    Quang

  5. #5
    Join Date
    May 2002
    Posts
    14

    emm ok

    but what i wanted to know, is after i register the class and etc, i do i connect it to the dialog

  6. #6
    Join Date
    Apr 1999
    Posts
    27,449

    Re: emm ok

    Originally posted by cyberia_2ooo
    but what i wanted to know, is after i register the class and etc, i do i connect it to the dialog
    In the RC file, specify the custom control there. Use the registered class name in the CONTROL entry in the dialog resource.

    Why not create a dialog, add a rich edit control, and then inspect the resource file? Then you will see how a custom control such as a rich edit field is specified in the dialog. Use this as a guide. Or just get any third-party custom control and see how you integrate it in your application. This again should give you some idea of how all of this is done.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; January 2nd, 2004 at 04:34 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured