Win32api: How to send a Struct in DialogBox?

starcanopy starcanopy at protonmail.com
Tue Oct 13 22:46:36 UTC 2020


On Tuesday, 13 October 2020 at 22:26:35 UTC, Marcone wrote:
> struct Teste {
>     string nome = "Paul";
>     int idade = 33;
> }
>
> extern(Windows):
> BOOL DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM 
> lParam) nothrow
> {
>     // I want to be able to use the struct object here.
>     // writeln(test.nome);
>     return false;
> }
>
> void chamaJanela(){
>     Test test; // How to send this object to the DlgMain 
> function?
>     DialogBox(null, MAKEINTRESOURCE(IDD_DIALOG1), null, 
> &DlgMain);
> }

Instead of calling DialogBox, you might try DialogBoxParam[A|W].

>Before displaying the dialog box, the function passes an 
>application-defined
>value to the dialog box procedure as the lParam parameter of the 
>WM_INITDIALOG
>message. An application can use this value to initialize dialog 
>box controls.

- 
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-dialogboxparamw




More information about the Digitalmars-d-learn mailing list