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

ID: Q117357

2.50 2.60 WINDOWS kbinterop

The information in this article applies to:

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 KBSubcategory: FxtoolLck

Keywords          : kbcode FxtoolLck 
Version           : 2.50 2.60
Platform          : WINDOWS

Last Reviewed: May 22, 1998