source: trunk/src/comctl32/ccbase.c@ 2858

Last change on this file since 2858 was 2858, checked in by cbratschi, 26 years ago

Corel 20000212, TREEVIEW_Sort fix, CCBase

File size: 3.1 KB
Line 
1/* $Id: ccbase.c,v 1.1 2000-02-22 17:11:38 cbratschi Exp $ */
2/*
3 * COMCTL32 Base Functions and Macros for all Controls
4 *
5 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
6 */
7
8#include "winbase.h"
9#include "comctl32.h"
10#include "ccbase.h"
11
12BOOL checkVersion(INT iVersion)
13{
14 return TRUE; //CB: todo
15}
16
17//init-done
18
19PVOID initControl(HWND hwnd,DWORD dwSize)
20{
21 COMCTL32_HEADER *infoPtr = COMCTL32_Alloc(dwSize);
22
23 if (!infoPtr) return NULL;
24
25 setInfoPtr(hwnd,infoPtr);
26 infoPtr->dwSize = dwSize;
27 infoPtr->iVersion = 0;
28 infoPtr->fUnicode = IsWindowUnicode(hwnd);
29 infoPtr->uNotifyFormat = sendNotifyFormat(GetParent(hwnd),hwnd,NF_QUERY);
30
31 return infoPtr;
32}
33
34VOID doneControl(HWND hwnd)
35{
36 COMCTL32_HEADER *infoPtr = getInfoPtr(hwnd);
37
38 COMCTL32_Free(infoPtr);
39 setInfoPtr(hwnd,NULL);
40}
41
42//Default message handler
43
44LRESULT defComCtl32Proc(HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lParam,BOOL unicode)
45{
46 COMCTL32_HEADER *infoPtr;
47
48 switch (Msg)
49 {
50 case CCM_GETVERSION:
51 infoPtr = getInfoPtr(hwnd);
52 return infoPtr ? infoPtr->iVersion:0;
53
54 case CCM_SETVERSION:
55 infoPtr = getInfoPtr(hwnd);
56 if (infoPtr)
57 {
58 if (checkVersion((INT)wParam))
59 {
60 INT oldVersion;
61
62 oldVersion = infoPtr->iVersion;
63 infoPtr->iVersion = (INT)wParam;
64 return oldVersion;
65 } else return -1;
66 } else return 0;
67
68 case CCM_GETUNICODEFORMAT:
69 infoPtr = getInfoPtr(hwnd);
70 return infoPtr ? infoPtr->fUnicode:IsWindowUnicode(hwnd);
71
72 case CCM_SETUNICODEFORMAT:
73 infoPtr = getInfoPtr(hwnd);
74 if (infoPtr)
75 {
76 BOOL oldFormat;
77
78 oldFormat = infoPtr->fUnicode;
79 infoPtr->fUnicode = (INT)wParam;
80 return oldFormat;
81 } else return IsWindowUnicode(hwnd);
82
83 case WM_NOTIFY:
84 {
85 infoPtr = getInfoPtr(hwnd);
86
87 if (!infoPtr) break;
88
89 if (lParam == NF_REQUERY)
90 {
91 infoPtr->uNotifyFormat = sendNotifyFormat(GetParent(hwnd),hwnd,NF_QUERY);
92 if ((infoPtr->uNotifyFormat != NFR_ANSI) && (infoPtr->uNotifyFormat != NFR_UNICODE))
93 infoPtr->uNotifyFormat = IsWindowUnicode(GetParent(hwnd)) ? NFR_UNICODE:NFR_ANSI;
94 return infoPtr->uNotifyFormat;
95 } else if (lParam == NF_QUERY)
96 {
97 return infoPtr->uNotifyFormat;
98 }
99 break;
100 }
101 }
102
103 if (unicode)
104 return DefWindowProcW(hwnd,Msg,wParam,lParam);
105 else
106 return DefWindowProcA(hwnd,Msg,wParam,lParam);
107}
108
109LRESULT defComCtl32ProcA(HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lParam)
110{
111 return defComCtl32Proc(hwnd,Msg,wParam,lParam,FALSE);
112}
113
114LRESULT defComCtl32ProcW(HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lParam)
115{
116 return defComCtl32Proc(hwnd,Msg,wParam,lParam,TRUE);
117}
118
119//Notifications
120
121LRESULT sendNotify(HWND hwnd,UINT code)
122{
123 NMHDR nmhdr;
124
125 nmhdr.hwndFrom = hwnd;
126 nmhdr.idFrom = GetWindowLongA(hwnd,GWL_ID);
127 nmhdr.code = code;
128
129 return SendMessageA(hwnd,WM_NOTIFY,nmhdr.idFrom,(LPARAM)&nmhdr);
130}
131
132LRESULT sendNotifyFormat(HWND hwnd,HWND hwndFrom,LPARAM command)
133{
134 return SendMessageA(hwnd,WM_NOTIFYFORMAT,hwndFrom,command);
135}
Note: See TracBrowser for help on using the repository browser.