INSPPROC.C
资源名称:cbuilder.zip [点击查看]
上传用户:needlamp
上传日期:2007-01-07
资源大小:78k
文件大小:6k
源码类别:
Delphi控件源码
开发平台:
Visual C++
- #include <windows.h>
- #include "appmain.h"
- #include "inspproc.h"
- HWND hWndInspStyle, hWndObject, hWndSelect,hWndPropList;
- long CALLBACK __export InspWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- RECT rc;
- MINMAXINFO FAR *lpmmi;
- PAINTSTRUCT ps;
- HPEN hPen;
- HDC hMemDC;
- static HBITMAP hBmpDListUp,hBmpDListDn;
- static int BmpHeight =0;
- BITMAP bmp;
- switch(message)
- {
- case WM_CREATE:
- GetClientRect(hWnd,&rc);
- hWndInspStyle = CreateWindow("WNDSTYLE", "",WS_CHILD|WS_VISIBLE,
- 0, rc.bottom-19, rc.right, 19,
- hWnd, IDW_STYLE, hInst, NULL);
- if(hWndInspStyle ==NULL)
- {
- ErrorMessage("Create WndInspStyle failed!");
- return -1;
- }
- SendMessage(hWndInspStyle,WM_ADDITEM,IDW_STYLE,(LPARAM)(LPSTR)"特征");
- SendMessage(hWndInspStyle,WM_ADDITEM,IDW_STYLE+1,(LPARAM)(LPSTR)"方法");
- SendMessage(hWndInspStyle,WM_ADDITEM,IDW_STYLE+2,(LPARAM)(LPSTR)"事件");
- hBmpDListUp =LoadBitmap(hInst, "BMP_DLISTUP");
- hBmpDListDn =LoadBitmap(hInst, "BMP_DLISTDN");
- if(!hBmpDListUp |!hBmpDListDn)
- {
- ErrorMessage("Load BMP_DLIST Failed!");
- return -1;
- }
- GetObject(hBmpDListUp, sizeof(bmp),(LPSTR)&bmp);
- BmpHeight =bmp.bmHeight;
- hWndObject =CreateWindow("LISTBOX","",WS_CHILD |LBS_SORT |WS_VSCROLL,
- 3,3+BmpHeight,rc.right-6,100,
- hWnd, IDW_OBJECT, hInst, NULL);
- if(hWndObject ==NULL)
- {
- ErrorMessage("Create Object List failed!");
- return -1;
- }
- hWndPropList = CreateWndPropList( hWnd, 0, 3+BmpHeight+4, rc.right+1,
- rc.bottom-20-BmpHeight-STYLE_WND_HEIGHT );
- if(hWndPropList ==NULL)
- {
- ErrorMessage("Create WndPropList failed!");
- return -1;
- }
- return 0L;
- case WM_ACTIVATEAPP:
- if(wParam)
- SetActiveWindow(hWnd);
- break;
- case WM_SETFOCUS:
- return 0L;
- case WM_GETMINMAXINFO:
- lpmmi=(MINMAXINFO FAR *)lParam;
- lpmmi->ptMinTrackSize.x=120;
- lpmmi->ptMinTrackSize.y=200;
- break;
- case WM_SIZE:
- if(wParam == SIZE_MINIMIZED) break;
- MoveWindow(hWndInspStyle, 0, HIWORD(lParam)-19,
- LOWORD(lParam),19,TRUE);
- MoveWindow(hWndPropList, 0, 3+BmpHeight+4, LOWORD(lParam)+1,
- HIWORD(lParam)-20-BmpHeight-STYLE_WND_HEIGHT,TRUE );
- return 0L;
- case WM_PAINT:
- BeginPaint(hWnd,&ps);
- GetClientRect(hWnd,&rc);
- SelectObject(ps.hdc, GetStockObject(WHITE_BRUSH));
- SelectObject(ps.hdc, GetStockObject(BLACK_PEN));
- Rectangle(ps.hdc, 3,3,rc.right-3,BmpHeight+3);
- hPen =CreatePen(PS_SOLID,1,RGB(80,80,80));
- SelectObject(ps.hdc,hPen);
- MoveTo(ps.hdc,2,BmpHeight+2);
- LineTo(ps.hdc,2,2);
- LineTo(ps.hdc,rc.right-3,2);
- MoveTo(ps.hdc,0,BmpHeight+5);
- LineTo(ps.hdc,rc.right,BmpHeight+5);
- SelectObject(ps.hdc,GetStockObject(WHITE_PEN));
- DeleteObject(hPen);
- MoveTo(ps.hdc, 3,BmpHeight+3);
- LineTo(ps.hdc, rc.right-3,BmpHeight+3);
- LineTo(ps.hdc, rc.right-3,2);
- MoveTo(ps.hdc, 0,BmpHeight+6);
- LineTo(ps.hdc, rc.right,BmpHeight+6);
- hMemDC =CreateCompatibleDC(ps.hdc);
- SelectObject(hMemDC, hBmpDListUp);
- GetObject(hBmpDListUp, sizeof(bmp),(LPSTR)&bmp);
- BitBlt(ps.hdc, rc.right-3-bmp.bmWidth,3,bmp.bmWidth,bmp.bmHeight,
- hMemDC, 0,0,SRCCOPY);
- DeleteObject(hMemDC);
- EndPaint(hWnd,&ps);
- break;
- case WM_SYSCOMMAND:
- switch(wParam)
- {
- case SC_KEYMENU:
- hWndPrev =hWnd;
- SetFocus(hWndMain);
- SendMessage(hWndMain,WM_SYSCOMMAND,wParam,lParam);
- return 0L;
- case SC_PREVWINDOW:
- break;
- }
- break;
- case WM_CLOSE:
- ShowWindow(hWnd,SW_HIDE);
- return 0L;
- case WM_DESTROY:
- if(hBmpDListUp) DeleteObject(hBmpDListUp);
- if(hBmpDListDn) DeleteObject(hBmpDListDn);
- hWndInsp =NULL;
- break;
- default:
- break;
- }
- return (DefWindowProc(hWnd, message, wParam, lParam));
- }
- HWND CreateWndPropList(HWND hWndParent,int left, int top, int width,int height)
- {
- HWND hWnd;
- WNDCLASS wc;
- wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
- wc.lpfnWndProc = PropListWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInst;
- wc.hIcon = LoadIcon(hInst, "ICON_YW");
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = GetStockObject(LTGRAY_BRUSH);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = "PROPLISTBOX";
- if(!RegisterClass(&wc)) return NULL;
- hWnd = CreateWindow("PROPLISTBOX", "PropListBox",
- WS_CHILD|WS_VISIBLE|LBS_NOTIFY|LBS_OWNERDRAWFIXED|LBS_NOINTEGRALHEIGHT
- |WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VSCROLL,
- left,top,width,height,
- hWndParent, IDW_STYLE, hInst, NULL);
- return hWnd;
- }
- long CALLBACK __export PropListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- return (DefWindowProc(hWnd, message, wParam, lParam));
- }