How to Create a Child "Windows" Window Using the LCK

Last reviewed: April 30, 1996
Article ID: Q117357
The information in this article applies to:
  • Microsoft FoxPro Library Construction Kit for Windows, versions 2.5, 2.6

SUMMARY

As shown below, you can use the FoxPro Library Construction Kit to create a child "Windows" window that can be manipulated within FoxPro. Using this method, you can create a window procedure that can receive Windows messages such as WM_PAINT.

MORE INFORMATION

FoxPro Sample Code

SET LIBRARY TO Showind.fll =ShowTheWind()

C Sample Code

#include <windows.h>
#include <pro_ext.h>

HINSTANCE hinst,mhinst ;
char szClass[] = "Class";
HWND hwndWindow = NULL; MSG msg; WNDCLASS wc;

long FAR PASCAL WndProc(HWND hWnd, UINT message, WORD wParam, LONG lParam);

HINSTANCE Inst;

void ShowTheWindow(ParamBlk FAR *parm)
{
   wc.style=0;
   wc.lpfnWndProc=WndProc;
   wc.cbClsExtra=0;
   wc.cbWndExtra=0;
   wc.hInstance=Inst;
   wc.hIcon=NULL;
   wc.hCursor=NULL;
   wc.hbrBackground=(HBRUSH)(COLOR_BACKGROUND + 5);
   wc.lpszMenuName=NULL;
   wc.lpszClassName=szClass;

   if(!RegisterClass(&wc))
      return ;
   hwndWindow = CreateWindow(szClass, "This is a child Window",
      WS_OVERLAPPED | WS_SYSMENU | WS_BORDER | WS_MINIMIZEBOX,
      CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,

   FindWindow(0,"Microsoft FoxPro"), NULL, Inst, NULL );
   ShowWindow(hwndWindow,SW_SHOW);
   UpdateWindow(hwndWindow);
}

long FAR PASCAL WndProc(HWND hWnd, unsigned message,WORD wParam, LONG lParam)

{

   PAINTSTRUCT ps;
   switch (message)
   {
      case WM_DESTROY:
         PostQuitMessage(0);
      case WM_PAINT:
         BeginPaint(hWnd,(LPPAINTSTRUCT)&ps);
         EndPaint(hWnd,(LPPAINTSTRUCT)&ps);
      default:
         return DefWindowProc(hWnd,message,wParam,lParam);
   }
return(0L); }

FoxInfo myFoxInfo[] = { {"SHOWWIND", (FPFI)ShowTheWindow, 0, ""}, };

FoxTable _FoxTable = { (FoxTable FAR *)0, sizeof(myFoxInfo) / sizeof(FoxInfo), myFoxInfo };

REFERENCES

Microsoft FoxPro Library Construction Kit "Developer's Guide," version 2.5 Microsoft Visual C++ "Programmer's Reference, Volume 2: Functions" "Programming Windows 3.1," Microsoft Press


Additional reference words: FoxWin 2.50 2.60 LCK API
KBCategory: kbinterop kbtool kbprg kbcode
KBSubcategory: FxtoolLck


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.