| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | SpinButton Quandary |
-=> Quoting Gary Chambers to All <=-
GC> I apologize for the lengthy code segment, but I'm not sure what's
GC> *NOT* needed. I'm having a difficult time (thinking it would be easy)
GC> with SpinButton controls. My desire is, simply, to have a small string
GC> displayed in a window as the button is changed (in any way). I cannot
GC> seem to grasp the use of SPBM_QUERYVALUE. My code will illustrate the
GC> method I'm using now. Any help will be greatly appreciated. Here's
GC> the code:
I made three changes, num is now static, the resultbuf for SPBM_QUERYVALUE
is a array of char, and intercept ID_SPINBUTTON from LOUSHORT(mp1),
SPBN_SETFOCUS, etc... are in HIUSHORT(mp1).
Note that SPBS_FASTSPIN skips some messages.
MRESULT EXPENTRY ClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
HPS hps;
RECTL rcl;
CHAR Prefix[] = "Spin Button value is now ";
CHAR szStr[80], _num[10];
static ULONG num; /* make static */
HWND spinID;
switch (msg)
{
case WM_CREATE:
/* Not sure if this is the correct way of getting the handle */
spinID = WinWindowFromID(hwnd, ID_SPINBUTTON);
/* Method different from WM_CONTROL because I was testing */
WinSendMsg(spinID, SPBM_QUERYVALUE, MPFROMSHORT(&num),
MPFROM2SHORT(SPBQ_ALWAYSUPDATE, 0));
return 0;
/* I'm getting the WM_CONTROL message (tested with DosBeep), */
/* but after that, nothing. */
case WM_CONTROL:
switch (SHORT1FROMMP(mp1))
{
/* I want to intercept *ANY* SpinButton message */
case ID_SPINBUTTON:
switch(HIUSHORT(mp1))
{
CHAR achBuf[5];
case SPBN_CHANGE:
WinSendMsg(HWNDFROMMP(mp2), SPBM_QUERYVALUE,
(PVOID)&achBuf,
MPFROM2SHORT(sizeof(achBuf), 0));
num = (ULONG)atol(achBuf);
WinQueryWindowRect(hwnd, &rcl);
WinInvalidateRect(hwnd, &rcl, TRUE);
break;
}
break;
}
return 0;
case WM_PAINT:
hps = WinBeginPaint(hwnd, 0, NULL);
WinQueryWindowRect(hwnd, &rcl);
WinFillRect(hps, &rcl, CLR_BACKGROUND);
rcl.xLeft += 5; rcl.yTop -= 5;
strcpy(szStr, Prefix);
itoa(num, _num, 10);
strcat(szStr, _num);
WinDrawText(hps, -1, szStr, &rcl, CLR_NEUTRAL, CLR_BACKGROUND,
DT_ERASERECT);
WinEndPaint(hps);
return 0;
} /* switch */
return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
Phil
Fido: 1:124/8014.1 | Internet: phil.crown{at}bluecafe.com
___ Blue Wave/OS2 v2.22b
--- WILDMAIL!/WC v4.12
* Origin: The Blues Cafe (214) 638-1186 8 Nodes (1:124/8014.0)SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955 SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809 @PATH: 124/8014 8001 1 396/1 270/101 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.