| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 464 人关注过本帖
标题:向大家请教
取消只看楼主 加入收藏
radcat
Rank: 3Rank: 3
等 级:论坛游民
威 望:8
帖 子:306
专家分:45
注 册:2006-9-12
收藏
 问题点数:0 回复次数:0 
向大家请教

在压缩文档中是一个用API创建的多文档窗口框架,如果大家用API编程相信这个框架更改很方便,但在程序中有一处问题,即子窗口最大化后子窗口按钮无响应,希望版主和各位高手予以解答.
谢谢:radcat

RoDqaGDT.rar (411.41 KB) 向大家请教



以下是代码部分:
// MeMdi.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "resource.h"

#define MAX_LOADSTRING 100
#define IDM_FIRSTCHILD 50000

// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text


TCHAR szAppName[] = TEXT ("MDIDemo") ;
TCHAR szFrameClass[] = TEXT ("MdiFrame") ;
TCHAR szHelloClass[] = TEXT ("MdiHelloChild") ;

// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
ATOM MyRegisterClassMdi(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK HelloWndProc(HWND, UINT, WPARAM, LPARAM);

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
HWND Client;

// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_MEMDI, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
MyRegisterClassMdi(hInstance);

// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}

hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_MEMDI);

// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
Client = GetWindow(msg.hwnd , GW_CHILD);
if (!TranslateMDISysAccel (Client, &msg) &&
!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return msg.wParam;
}

//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)FrameWndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_MEMDI);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_MEMDI;
wcex.lpszClassName = szFrameClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

return RegisterClassEx(&wcex);
}

ATOM MyRegisterClassMdi(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)HelloWndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_MEMDI);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szHelloClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hwndFrame;

hInst = hInstance; // Store instance handle in our global variable

hwndFrame = CreateWindow(szFrameClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

if (!hwndFrame)
{
return FALSE;
}

ShowWindow(hwndFrame, nCmdShow);
UpdateWindow(hwndFrame);

return TRUE;
}

//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND hwndClient ;
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

CLIENTCREATESTRUCT clientcreate ;
HWND hwndChild ;
MDICREATESTRUCT mdicreate ;
HMENU hMenuInitWindow;

switch (message)
{
case WM_CREATE:
hMenuInitWindow = GetSubMenu((HMENU)IDC_MEMDI,0);
clientcreate.hWindowMenu = hMenuInitWindow ;
clientcreate.idFirstChild = IDM_FIRSTCHILD ;

hwndClient = CreateWindow (TEXT ("MDICLIENT"), NULL,
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
0, 0, 0, 0, hWnd, (HMENU) 1, hInst,
(PSTR) &clientcreate) ;
return 0 ;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case ID_NEW:

mdicreate.szClass = szHelloClass ;
mdicreate.szTitle = TEXT ("Hello") ;
mdicreate.hOwner = hInst ;
mdicreate.x = CW_USEDEFAULT ;
mdicreate.y = CW_USEDEFAULT ;
mdicreate.cx = CW_USEDEFAULT ;
mdicreate.cy = CW_USEDEFAULT ;
mdicreate.style = 0 ;
mdicreate.lParam = 0 ;

hwndChild = (HWND) SendMessage (hwndClient,
WM_MDICREATE, 0,
(LPARAM) (LPMDICREATESTRUCT) &mdicreate) ;
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;

case IDM_WINDOW_TILE:
SendMessage (hwndClient, WM_MDITILE, 0, 0) ;
return 0 ;

case IDM_WINDOW_CASCADE:
SendMessage (hwndClient, WM_MDICASCADE, 0, 0) ;
return 0 ;

case IDM_WINDOW_ARRANGE:
SendMessage (hwndClient, WM_MDIICONARRANGE, 0, 0) ;
return 0 ;

case IDM_WINDOW_CLOSEALL: // Attempt to close all children

//EnumChildWindows (hwndClient, CloseEnumProc, 0) ;
return 0 ;

case IDM_FILE_CLOSE:
//获得当前激活窗口
hwndChild = (HWND) SendMessage (hwndClient, WM_MDIGETACTIVE, 0, 0);
//询问通过后,销毁窗口
if (SendMessage (hwndChild, WM_QUERYENDSESSION, 0, 0))
SendMessage (hwndClient, WM_MDIDESTROY, (WPARAM) hwndChild, 0);
return 0;

default: // Pass to active child...

hwndChild = (HWND) SendMessage (hwndClient,
WM_MDIGETACTIVE, 0, 0) ;

if (IsWindow (hwndChild))
SendMessage (hwndChild, WM_COMMAND, wParam, lParam) ;

break ; // ...and then to DefFrameProc
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);

EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefFrameProc (hWnd, hwndClient, message, wParam, lParam) ;
}
return 0;
}

// Mesage handler for about box.
LRESULT CALLBACK HelloWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
static int i,j;
switch (message)
{
case WM_LBUTTONDOWN:
hdc=GetDC(hDlg);
TextOut(hdc,0,0,"an mdi window",strlen("an mdi window"));
ReleaseDC(hDlg,hdc);
break;
case WM_RBUTTONDOWN:
hdc=GetDC(hDlg);
Rectangle(hdc,50,50,200,200);
ReleaseDC(hDlg,hdc);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_RECT:
i=255;
j=0;
InvalidateRect (hDlg, NULL, FALSE) ;
break;
case ID_BLUE:
j=255;
i=0;
break;
}
break;
case WM_PAINT:
// Paint the window
RECT rect;
hdc = BeginPaint (hDlg, &ps) ;
GetClientRect (hDlg, &rect) ;
SetTextColor(hdc,RGB(i,j,0));
DrawText (hdc, TEXT ("Hello, World!"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
EndPaint (hDlg, &ps) ;
return 0 ;
case WM_QUERYENDSESSION:
case WM_CLOSE:
if (IDOK != MessageBox (hDlg, TEXT ("OK to close window?"),
TEXT ("Hello"),
MB_ICONQUESTION | MB_OKCANCEL))
return 0 ;

break ; // i.e., call DefMDIChildProc
}

return DefMDIChildProc (hDlg, message, wParam, lParam) ;
}



DnUxACdO.rar (488.39 KB) 向大家请教



fek8ISra.rar (488.39 KB) 向大家请教

2006-09-12 17:23
快速回复:向大家请教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017783 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved