Author Topic: Filling Comboboxes  (Read 6580 times)

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 345
  • Karma: +29/-0
    • View Profile
Filling Comboboxes
« on: August 20, 2023, 11:17:27 am »
I have the launcher dialog for PrBoom+ setup with the appended RC file (compiled with WRC) inside the WM_INITDLG call.
I try to fill a combox with LM_INSERTITEM, but the strings are not displayed, while not returning. The code, I use is like this:
Code: [Select]
WinSendMsg(launcher.listIWAD, LM_INSERTITEM, MPFROMSHORT(LIT_END), MPFROMP((PSZ)iwadname))launcher.listIWAD is the handle of the control fetched by WinWindowFromID. iwadname is a char array filled with the display string.
The strange part is that I can fill the command combobox and the files listbox, but not the games and the history comboboxes.
I tried to send the messages by calling WinSendDlgItemMsg or converting the combobox into a listbox. No changes.

Does anyone have a clue, whats going on here?

Lars

  • Hero Member
  • *****
  • Posts: 1279
  • Karma: +65/-0
    • View Profile
Re: Filling Comboboxes
« Reply #1 on: August 20, 2023, 11:49:24 am »
Make sure that all combo boxes have the same attributes in the RC file. Then, you might need to create groups and have that combo box be part of a group.
« Last Edit: August 20, 2023, 11:53:21 am by Lars »

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 345
  • Karma: +29/-0
    • View Profile
Re: Filling Comboboxes
« Reply #2 on: August 21, 2023, 10:57:03 am »
@Lars: Unfortunately, putting the comboboxes in (a) group(s) didn't help. The attributes are all the same.

Lars

  • Hero Member
  • *****
  • Posts: 1279
  • Karma: +65/-0
    • View Profile
Re: Filling Comboboxes
« Reply #3 on: August 21, 2023, 03:04:19 pm »
always return TRUE from WM_INITDLG (I do not know why).
You could also call WinUpdateWindow for the whole dialog (that includes its childen) to update all controls before returning from WM_INITDLG.

Other than that I would need to see the full code.
« Last Edit: August 21, 2023, 03:06:11 pm by Lars »

Rich Walsh

  • Sr. Member
  • ****
  • Posts: 339
  • Karma: +23/-0
  • ONU! (OS/2 is NOT Unix!)
    • View Profile
Re: Filling Comboboxes
« Reply #4 on: August 21, 2023, 07:09:34 pm »
The most likely cause is a dialog-ID mismatch resulting in a null hwnd (or less likely, the wrong hwnd). A null string (i.e. "") is also a possibility. Use an fprintf() immediately before the failing call  to confirm, e.g.

Code: [Select]
fprintf(stderr, "hwnd= %x  str= %x - %s\n), launcher.listIWAD, iwadname, (iwadname ? iwadname : "null");

Run the app using "xxx.exe 2>&1 | tee"

FWIW... there's no need to suplpy a log file name if using GNU 'tee' (unless you want a log).

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 345
  • Karma: +29/-0
    • View Profile
Re: Filling Comboboxes
« Reply #5 on: August 22, 2023, 10:03:49 am »
The most likely cause is a dialog-ID mismatch resulting in a null hwnd (or less likely, the wrong hwnd). A null string (i.e. "") is also a possibility. Use an fprintf() immediately before the failing call  to confirm, e.g.

Code: [Select]
fprintf(stderr, "hwnd= %x  str= %x - %s\n), launcher.listIWAD, iwadname, (iwadname ? iwadname : "null");

Run the app using "xxx.exe 2>&1 | tee"

FWIW... there's no need to suplpy a log file name if using GNU 'tee' (unless you want a log).
All the handles are not null. I also used WinSendDlgItemMsg, but actually none of the LM_INSERT messages fail. They all return 0 as index, which should be valid value.
For the IDs, I used constants, so I can avoid ID mismatches.
I put the code in an extra branch:
Code: [Select]
https://github.com/josch1710/prboom-plus-os2/tree/launcher.
The resource files are in prboom2/ICONS/ and the C code is in prboom2/src/os2_launcher.c

Lars

  • Hero Member
  • *****
  • Posts: 1279
  • Karma: +65/-0
    • View Profile
Re: Filling Comboboxes
« Reply #6 on: August 22, 2023, 04:19:23 pm »
Add WS_TABSTOP (and also WS_GROUP to be sure) to each combobox element in the RC file.
« Last Edit: August 22, 2023, 04:42:20 pm by Lars »

Rich Walsh

  • Sr. Member
  • ****
  • Posts: 339
  • Karma: +23/-0
  • ONU! (OS/2 is NOT Unix!)
    • View Profile
Re: Filling Comboboxes
« Reply #7 on: August 22, 2023, 07:02:17 pm »
Add WS_TABSTOP (and also WS_GROUP to be sure) to each combobox element in the RC file.

These flags exist solely for the benefit of the default dialog proc and have no effect on the operation of the control that's flagged.

BTW... the use of the ES_ANY flag for the comboboxes serves no purpose. ES_ANY is the default and equates to zero.

Lars

  • Hero Member
  • *****
  • Posts: 1279
  • Karma: +65/-0
    • View Profile
Re: Filling Comboboxes
« Reply #8 on: August 22, 2023, 09:30:24 pm »
Found the error. You have been using the same id for one of the static text strings and your combobox.
I'll bundle up my test proggie and send it to you, including the corrected rc/h files.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 345
  • Karma: +29/-0
    • View Profile
Re: Filling Comboboxes
« Reply #9 on: August 23, 2023, 11:09:43 am »
Thanks, Lars. I feel a little silly, for only checking the non-static items.

While we are at it:
I couldn't find a message to do this, but how can I  programmatically change a static text? If it is not possible with SS_TEXT, how else could I do it?

Lars

  • Hero Member
  • *****
  • Posts: 1279
  • Karma: +65/-0
    • View Profile
Re: Filling Comboboxes
« Reply #10 on: August 23, 2023, 11:47:43 am »
Thanks, Lars. I feel a little silly, for only checking the non-static items.

While we are at it:
I couldn't find a message to do this, but how can I  programmatically change a static text? If it is not possible with SS_TEXT, how else could I do it?

WinSetWindowText

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 345
  • Karma: +29/-0
    • View Profile
Re: Filling Comboboxes
« Reply #11 on: August 23, 2023, 12:28:47 pm »
Thanks