Thread: Custom Control

  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
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    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
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    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
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    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
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    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
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    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.

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, 03:21 PM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  3. Custom control information
    By Mithoric in forum Windows Programming
    Replies: 6
    Last Post: 03-02-2004, 06: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