Subj : Using Prf* routines in window procs
To : Vitus Jensen
From : Herbert Rosenau
Date : Sat Jun 03 2000 03:53 pm
Am 30.05.00 00:04 schrieb Vitus Jensen
VJ> Hej!
VJ> Does anybody know whether Prf* routines are usable from inside a
VJ> window proc? Do they block or violate the 1/10s rule in any other
VJ> way?
Use them when you need them!
VJ> Currently I'm using my own Profile routines which are working on
VJ> memory structures and dump the new contents to disk whenever
VJ> WM_SAVEAPPLICATION is called. If PrfReadProfileData /
VJ> PrfWriteProfileData routines use the same scheme (i.e no file
VJ> access) it would double the memory requirements without need.
All Prf functions have ony one thing to do: read/write to given profile file.
General hints:
1. create you windows hidden!
Means Let the frame window miss! the WS_VISIBLE
But let all its childs have the WS_VISIBLE set!
2. fill in all data you have to fill
3. if all is done change the visible state!
During process:
Whenever you have al lot of work on your vsible window do the steps
1. WinSetWindowUpdate(hwnd, FALSE)
2. upate all of them - there is absolutly nothing drawn yet! (saves a lot of
time)
3. if all work done: WinSetWindowUpdate(hwnd, TRUE)
does the real drawing - once one!
OWNERDRAWing is done now!
Another trick for LISTBOX, COMBOBOX, CONTAINER:
Use always the style OWNERDRAW - and insert ONLY a (shorthand to text
converted) Pointer to the real data you would draw. This would save a lot of
memory inside PM - Nobody says that you have to fill the items with all real
data you have to show! But only GPI has to draw them right. And for that you
need a pointer or index inside the item that says YOU what data is to display.
Draw it by yourself. You can't insert any binary data into your Items - for
that you must convert them to anything that looks like text.
One of the tuning effects in sqed 2.0:
1. save a lot of memory by holding only a minimum bytes inside the listbox
and not all data needed to draw
2. save a lot of time in
- copying only a minimum bytes into listbox
- compare indirectly - and not the whole data
/* Fuction P2X */
/* */
/* Convert a (previous to string converted) pointer back to its binary */
/* representation. See P2X() for details. */
/* */
/* Parameter: */
/* */
/* PCHAR p pointer to external representation */
/* to a pointer. */
/* */
/* Return: */
/* */
/* PVOID the binary pointer */
/* */
/* */
PVOID X2P(PCHAR p) {
ULONG u = 0;
ULONG i;
for (i = 0; i < (2 * sizeof(PVOID)); i++) {
u <<= 4; /* make room for next digit */
u |= (*p++ & 0x0f); /* only the lower digit of that byte */
} /* endfor */
return (PVOID) u; /* return as pointer to void */
}
/* Fuction P2X */
/* */
/* Convert a pointer to external format. */
/* This isn't a real hex but seems so. This function is needed to convert */
/* the binary pointer into a printable format. Because a PM control */
/* (e.g. listbox) can't handle binary data and we will use often a simple */
/* pointer to a data struct instead of real data - and then in ownerdraw */
/* display the real data. */
/* */
/* This is done to save a lot of memory. */
/* */
/* Parameter: */
/* */
/* PVOID a the pointer to convert */
/* PCHAR p points to a buffer of 9 bytes. */
/* It's on caller to hold that buffer */
/* in size of 9 bytes or bigger. */
/* */
/* Return: */
/* */
/* PCHAR a pointer to converted string */
/* The lower digits are the info we got */
/* This is identical with p. */
/* We'll return it to become a fuction */
/* ready as parameter for printf(), */
/* strcpy() or so. */
/* */
PCHAR P2X(PVOID a, PCHAR p) {
PCHAR v = a; /* treate the pointer as pointer to CHAR */
ULONG i;
PCHAR p2 = p:
/* Fuction AreaFillArea */
/* */
/* Fill an Listbox with all areas */
/* only the pointer to AREA is stored, the draw action has */
/* to draw the real content. */
/* */
/* Parameter: */
/* */
/* HWND hwnd HWND of Window containing the listbox */
/* ULONG id ID of Listbox */
/* */
/* return: - */
/* */
VOID AreaFillArea(HWND hwnd, ULONG id) {
HWND hwndLB = WinWindowFromID(hwnd, id); /* get the listbox itself */
PAREA pArea = Areas->pNext;
CHAR areaName[9];
/* Fuction AreaPaintLBItemName */
/* */
/* Paint an item of AREA listbox. The listbox itself contains only a */
/* pointer to the area description. We have to get all info to paint from */
/* the AREA member. Here we paint only the areaname. */
/* */
/* See AreaPaintLBItem() for a more complex painting */
/* */
/* Parameter: */
/* */
/* POWNERITEM poiItem the item to draw */
/* */
/* return: - */
/* */
VOID AreaPaintLBItemName(POWNERITEM poiItem) {
COLOR clrForeGround;
COLOR clrBackGround;
RECTL rcl;
CHAR achpArea[9];
PAREA pArea;