🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12591

MDI

#12591
From: davidwilliams
Date: Thu, 27 Nov 2003 21:10
127 lines
4568 bytes
Hello
      I am writing an MDI app using the API functions directly. I am using
     the child forms to eventually display data from the COMM port.
  As  a test I have set the child forms to display data from the
keyboard, I have also set a progress bar as a child of the frameWindow
and I am using this as a gauge. The only way I can get the gauge and
children to respond to the key board is if I do the following***:

frameWindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ switch(message)
 {
           case WM_CHAR:

   SendMessage(hpbarwnd, PBM_SETPOS,0,0);
   //(char)wParam; //String size character

   if(hpbarwnd)
     pBarPos=SendMessage(hpbarwnd,PBM_SETPOS,(char)wParam,0);

                        //function that iterates through the children shown
below
   SendKeyToChild(wParam);
   //for(i=0; i<childCount; i++)
  // {
             // SendMessage(hchildwnd, WMDI_ACTIVATE,
   //}
   break;

          case.....



          case WM_COMMAND:
          switch(LOWORD(wParam))
          {




            default:   DefFrameProc(hwnd, hclientwnd, message, wParam,
lParam);

          }//end of inner switch

       //This is where the problem is if I swap this line***
       default return    DefFrameProc(hwnd, hclientwnd, message, wParam,
lParam);
      //For this line ***
      default return   DefWindowProc(hwnd, message, wParam, lParam);
     /*Then the frameWindow gets the key board focus, I have tried using
various SetFocus(hframewnd) etc but
        the client still gets the focus until I swap the DefFrameProc() with
DefWindowProc(). I have also noticed that the system
       seems to only receive the every second key press with the
DefFrameProc() method
    */

   }//End of outer switch
return 0;
}

void SendKeyToChild(WPARAM key)
{
 LRESULT childRes;
 char str[20];
 HDC hdc;
    int childIterator;


      if(childCount!=-1) //Are there any children present....
     {

        //Returns a handle to the active child window
        childRes=SendMessage(hclientwnd,WM_MDIGETACTIVE,0,0);

        //Get the child Window's DC
        hdc=GetDC((HWND)childRes);
        TextOut(hdc,60,60,"   ", 3);//Erase old character
     sprintf(str, "%c", (char)key);
        //Output the text to the active child window
        TextOut(hdc,60,60,str, strlen(str));
        //Release the device context.
        ReleaseDC((HWND)childRes, hdc);

             //Iterate through the children
             for(childIterator=0; childIterator<=childCount;
childIterator++)
            {
                //Iterate to the next child in the Z order?

                strcpy(Cdata[childIterator]->str, str);
                childRes=SendMessage(hclientwnd,WM_MDINEXT,0,0);

               //Returns a handle to the active child window
              childRes=SendMessage(hclientwnd,WM_MDIGETACTIVE,0,0);
              hdc=GetDC((HWND)childRes);
             TextOut(hdc,60,60,"   ", 3);//Erase old character
             sprintf(str, "%c", (char)key);
             //Output the text to the active child window
             TextOut(hdc,60,60,str, strlen(str));
            //Release the device context.
           ReleaseDC((HWND)childRes, hdc);

     }
  }

}


//winMain message processing loop
 while(GetMessage(&msg, NULL,0,0)>0)
 {

  if(!TranslateMDISysAccel(hclientwnd, &msg) &&
   !TranslateAccelerator(hframewnd,hAccel, &msg))
  {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }
 }
 return msg.wParam;

has anyone any ideas on this. am I approaching this all wrong?, this is my
first attempt at an MDI solution. Note all the Accelerator keys are working
fine
thanks
Dave.
Technical Details
Message-ID: <3fc7b9cd@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,c213bc6d153de4,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-11-28 13:27:32 PST
From: "davidwilliams" <david@williams7679.freeserve.co.uk>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: MDI
Date: Thu, 27 Nov 2003 21:10:07 -0000
Lines: 129
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 81.76.222.16
Message-ID: <3fc7b9cd@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1070053837 81.76.222.16 (28 Nov 2003 13:10:37 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail