Microsoft KB Archive/117357

{| = How to Create a Child "Windows" Window Using the LCK =
 * width="100%"|

ID: Q117357

2.50 2.60 WINDOWS kbinterop

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.

FoxPro Sample Code
SET LIBRARY TO Showind.fll =ShowTheWind

C Sample Code
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);
 * 1) include 
 * 2) include 

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 };