realbasic-plugins
[Top] [All Lists]

Re: controlHandleGetter question

To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
Subject: Re: controlHandleGetter question
From: Alfred Van Hoek <vanhoek at mac dot com>
Date: Fri, 20 Jan 2006 06:53:04 -0500
Delivered-to: realbasic-plugins at lists dot realsoftware dot com
References: <BFF1B677 dot 41548%listmail1 at dsl dot pipex dot com> <6A88C6E6-5DB7-460A-8011-3952CCEBE825 at gmx dot net> <E29A17C6-623B-424D-BFEA-5F0EC3FBD8DA at chaoticbox dot com> <003951F9-5CF2-4D16-B319-D74BA6A7367A at gmx dot net> <120B038C-FC52-432B-A6A6-42DA59B5F4C1 at chaoticbox dot com> <43D07959 dot 1040805 at axel dot ocn dot ne dot jp>

On Jan 20, 2006, at 12:47 AM, Suikyo wrote:

I make REALcontrol.

Because I cannot acquire HWND of control with initFunction of behavior and openFunction, I acquire it with controlHandleGetter.

The initFunction on Mac and Windows and openFunction on WIndows are fired to early to obtain a valid HWND from a REALcontrolInstance and therefore you indeed should inquire about a HWND after these instance-callbacks. I presume that the following code is called after these callbacks, since you obtain a valid HWND.


A source is as follows.

ULONG controlHandleGetter( REALcontrolInstance instance )
{
  ControlData(ListViewExControl,instance,LSTVIEWX,data);
  HWND  hwnd;
  hwnd = REALGetControlHandle( instance );
  if(REALinRuntime()){
    if(hwnd && data->hWnd==NULL)
    {
      data->hWnd = hwnd;

      //CreateWindowEx and set control style
      _lvx_on_create(instance);

      //Fire true Open event
      void (*fp)(REALcontrolInstance instance);
fp = (void (*)(REALcontrolInstance instance)) REALGetEventInstance(instance, &lvxEvents[0]);
      if (fp) fp(instance);

I presume that your REALeventInstance (lvxEvents[0]) is defined as "Open", and this is problematic because RB defines already an "Open" event for any REALcontrol. Change the definition of lvxEvents[0] into "MyOpen" to test. Then you should be able to set properties of your control in the "MyOpen" event.


      lvxStateChanged(instance,kBoundsChanged);
      UINT  id;
data->hThread = (HANDLE)_beginthreadex( NULL, 0, &_lvx_threadproc, (LSTVIEWX*)data, 0, &id ); if((LONG)data->hThread==-1L) _DEBUG(L"failed _beginthreadex. (reason=%d)",GetLastError());
    }
  }
  return (ULONG)hwnd;
}

However, I can make control in this way, but the property that I set with IDE is not succeeded to.

What kind of case will you use controlHandleGetter for?

Don't know what you mean here. REALGetControlWIndow or REALGetHWND are the correct api's to obtain the HWND, and your code above looks fine to me, apart from assumptions raised above,

Alfred

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>