Custom Control

This is a discussion on Custom Control within the Windows Programming forums, part of the Platform Specific Boards category; ok, that about sums up the problem with the CALLBACK, any idea whats causing the CreateThread(...) error? m_hThread is a ...

  1. #16
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    ok, that about sums up the problem with the CALLBACK, any idea whats causing the
    CreateThread(...) error? m_hThread is a HANDLE..

  2. #17
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Did you post the error message for that?

  3. #18
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    yup, first post, the function call is in aButton::Create(..);

  4. #19
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    This one???

    Code:
    D:\Programming\C++\aButton.cpp(86) : error C2440: '=' : cannot convert from 'long (__stdcall *(__thiscall aButton::*)(struct HWND__ *,unsigned int,unsigned int,long))(struct HWND__ *,unsigned int,unsigned int,long)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
    
    D:\Programming\C++\aButton.cpp(74) : error C2440: 'type cast' : cannot convert from '' to 'unsigned long (__stdcall *)(void *)'
            None of the functions with this name in scope match the target type

  5. #20
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    yeah, its the bottom error.. it doesnt make any sense to me.. how can it be ''?

  6. #21
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    You're passing an incompatible function pointer (Main) in the 3rd argument of CreateThread.

    The function needs to be a static (or global) function that looks like

    Code:
    DWORD WINAPI ThreadProc(
      LPVOID lpParameter
    );

  7. #22
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    oh, so pretty much the same thing as the CALLBACK, make it static and set the handle with setwindowlong?

    also, i usually pass void functions to createthread and it works.. just not in a class.

  8. #23
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    oh, so pretty much the same thing as the CALLBACK, make it static and set the handle with setwindowlong?
    You can make it static but you can't set extra memory for threads using SetWindowLong.

  9. #24
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    hmm... would it be wrong to close the handle right after i create the thread? i wont need it anyway.. the thread should end whenever the control is destroyed, right?

    and by the way, thanks for all the help

  10. #25
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    IIRC, calling CloseThread() won't terminate the thread so yes, the thread will still run.

    But I think you should keep the handle around, because to completely remove a thread object you have to call CloseHandle() after the thread is terminated.

    My knowledge in this area is rusty, someone correct me if I'm wrong.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Superclassed edit control; custom notifications
    By Boksha in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2006, 02:21 PM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 05:23 AM
  3. Custom control information
    By Mithoric in forum Windows Programming
    Replies: 6
    Last Post: 03-02-2004, 05:52 AM
  4. Custom Tab Control
    By PrivatePanic in forum Windows Programming
    Replies: 8
    Last Post: 07-19-2002, 01:23 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21