Microsoft KB Archive/151257

= How to modify a Report Preview window property =

Article ID: 151257

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 9.0 Professional Edition

-



This article was previously published under Q151257



Note Microsoft Visual C++ .NET 2002 and Microsoft Visual C++ .NET 2003 support both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code.



INTRODUCTION
This article describes how to disable the Minimize property and the Maximize property of the Report Preview window in Microsoft Visual FoxPro by using API routines.

Note This technique works in Microsoft Visual FoxPro 9.0. However, you can also control the Report Preview window by using a Report Listener and the ReportPreview.app application.



MORE INFORMATION
By default, you can minimize or maximize the Report Preview window by clicking the buttons in the upper-right corner of the Report Preview window. Because the Report Preview window is a system-generated window, you must to call API routines to modify the Report Preview window. This article contains a customized API routine to remove the Minimize button and the Maximize button from the Report Preview window. This API routine was written by using Microsoft Visual C++ 6.0. You can also write this API routine by using Microsoft Visual Studio .NET.

The following sample program uses a .dll file that was written by using Visual C++ 6.0. The sample program shows how to disable the Minimize property and the Maximize property of the Report Preview window through the Microsoft Win32 Software Development Kit (SDK).

Note This sample program contains many Visual C++ commands. The use of these commands is beyond the scope of Microsoft Visual FoxPro Product Support. Users who have significant experience using API routines should be able to write the following sample .dll file.

Create the .dll file that the sample program will use
 Create a Win32 Dynamic-Link Library project in Visual C++ 6.0 or create a C++ Win32 project in Visual Studio .NET. Name the project Disable.

Note If you use Visual Studio. NET, make sure that you change the application settings to reflect that this project is a .dll that exports symbols.  Replace all the code in the main .cpp file with the following code sample.
 * 1) include "stdafx.h"
 * 2) include "Disable.h"


 * 1) define IDS_MEMVIEWCLASS       11005

BOOL APIENTRY DllMain(HANDLE hInst, DWORD ul_reason_being_called, LPVOID lpReserved) {  return 1; UNREFERENCED_PARAMETER(hInst); UNREFERENCED_PARAMETER(ul_reason_being_called); UNREFERENCED_PARAMETER(lpReserved); }

void DISABLE_API disable(char *title, char *header) { // This line is a handle for parent window. HWND hWnd, // This line is a handle for child window. hChild;

// Try to find the parent window of the Report Preview window. hWnd = FindWindow(NULL, title);

char title1[75];

// Try to find the first child window. hChild = GetWindow(hWnd,GW_CHILD); while (hChild != 0) {      hWnd = hChild; // Try to find the first sibling of the child window. hChild = GetWindow(hWnd,GW_HWNDNEXT); while (hChild != 0) {       hWnd = hChild; GetWindowText(hWnd,title1,75); if (strcmp(title1,header) == 0) { DWORD L;    // Disable the Minimize button and the Maximize button of the Report Preview window. L = GetWindowLong(hChild, GWL_STYLE); L = L & ~(WS_MINIMIZEBOX); L = L & ~(WS_MAXIMIZEBOX); SetWindowLong(hChild,GWL_STYLE,L); // Redraw the Report Preview window. SetWindowPos(hChild,NULL,0,0,0,0, SWP_DRAWFRAME|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE); return; }       hChild = GetWindow(hWnd,GW_HWNDNEXT); }    hChild = GetWindow(hWnd,GW_CHILD); } return; }   Open the header file. Add the following line of code at the bottom of the file. extern "C" DISABLE_API void disable(char *, char *);  In the header file, remove the declarations for any other functions. Build the project to create the Disable.dll file.

Create the sample program for Visual FoxPro
Use the following code sample for Visual FoxPro 7.0. REPORT FORM HOME(2)+"tastrade\reports\salessum.frx" PREVIEW nowait DECLARE integer disable IN KBTest.DLL string, string =disable("Microsoft Visual FoxPro",; "Report Designer - salessum.frx - Page 1") Use the following code sample for Visual FoxPro 8.0 and for Visual FoxPro 9.0. REPORT FORM HOME(2)+"solution\reports\colors.frx" PREVIEW nowait DECLARE integer disable IN KBTest.DLL string, string =disable("Microsoft Visual FoxPro",; "Report Designer - colors.frx - Page 1")

Sample program notes

 * To create a .dll file in Visual C++, see the Help file in Microsoft Visual C++ 6.0 or in Visual Studio .NET.
 * Save the Disable.dll file in the same folder as your project or in the path of the Windows Win32 folder.
 * The API function must have two parameters. The first parameter is the caption of the main application window. Typically, this window is a Visual FoxPro window. The second parameter is the caption of the Report Preview window for which you want to disable the Minimize button and the Maximize button. If, for any reason, the sample program does not work correctly, verify the captions of these windows and then run the sample program again.

Additional query words: VFoxWin akz

Keywords: KB151257

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.