Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Subclass ComboBox
#1
Hi,

I want to use , and . to select items in the combobox

In the following code, I can successfully intercept , and . But the following operation does not work

[Image: aaa.png]

Q1:
Line53: Setting id 3 has no effect, 1001 has effect, It's a bit hard to understand
    SetWindowSubclass(id(1001 hDlg) &sub.WndProc_Subclass_ComboBox 1 0)

Q2:
How to subclass QM_ComboBox controls? Is this possible? e.g: qmcb6 qmcb7 qmcb8

I don't quite understand control subclassing

Thanks in advance for any advice and help
david

Macro subclass_combobox
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 ComboBox 0x54230242 0x0 8 24 96 213 ""
;4 ComboBox 0x54230242 0x0 8 48 96 213 ""
;5 ComboBox 0x54230242 0x0 8 72 96 213 ""
;6 QM_ComboBox 0x54030242 0x0 120 24 96 13 ""
;7 QM_ComboBox 0x54030242 0x0 120 48 96 13 ""
;8 QM_ComboBox 0x54030242 0x0 120 72 96 13 ""
;9 Static 0x54000000 0x0 8 8 48 12 "ComboBox"
;10 Static 0x54000000 0x0 120 8 48 12 "QM_ComboBox"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3 4 5 6 7 8"
str cb3 cb4 cb5 qmcb6 qmcb7 qmcb8
cb3=
;one
;two
;three
cb4=
;one
;two
;three
cb5=
;one
;two
;three
qmcb6=
;qmcb6
;one
;two
;three
qmcb7=
;qmcb7
;one
;two
;three
qmcb8=
;qmcb8
;one
;two
;three
if(!ShowDialog(dd &sub.DlgProc &controls)) ret

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SetWindowSubclass(id(1001 hDlg) &sub.WndProc_Subclass_ComboBox 1 0)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

#sub WndProc_Subclass_ComboBox
function# hwnd message wParam lParam uIdSubclass dwRefData

;OutWinMsg message wParam lParam ;;uncomment to see received messages

sel message
,case WM_CHAR
,sel(wParam)
,,case 0x2C ;; ,
,,;mes "Pressed the , key"
,,key D
,,ret
,,case 0x2E ;; .
,,;mes "Pressed the . key"
,,key U
,,ret
int R=DefSubclassProc(hwnd message wParam lParam)

sel message
,case WM_NCDESTROY
,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass_ComboBox uIdSubclass)
ret R
#2
ComboBox is has a child Edit control with id 1001
#3
From the control information bar at the bottom of QM
The id of all ComboBox and QM_ComboBox is 1001  Huh
#4
To understand it:

Run QM3,
move the mouse to an editable ComboBox control,
press Ctrl+Shift+W,
look at the bottom part of the "Find window" window.

It displays the tree of child windows of the window. You can see that the selected control is Edit, and it is a child of ComboBox. At the right side click link "Control"; it displays properties of the selected child window.
#5
succeed! I found a more stable way  Smile
 
Code:
Copy      Help
 
,,_i=CB_SelectedItem(GetParent(hwnd))
,,CB_SelectItem(GetParent(hwnd) _i+1)


Forum Jump:


Users browsing this thread: 1 Guest(s)