News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

TaskDialog

Started by guga, April 10, 2025, 07:17:48 AM

Previous topic - Next topic

guga

Hi Guys

Anyone ever succeeded to create a TaskDialog ?

References:
Link1
very good reference in VB6
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

NoCforMe

Um, I give up: what, exactly, is a "task dialog" and what does it do?
The referenced Micro$oft Learn page doesn't exactly satisfy my curiosity:
QuoteThe TaskDialogIndirect function creates, displays, and operates a task dialog. The task dialog contains application-defined icons, messages, title, verification check box, command links, push buttons, and radio buttons.
Any pictures available?

Looks do-able: if I weren't so damn lazy I'd try to code one up just to see what it looks like. (That TASKDIALOGCONFIG structure is a bitch, though!)
Assembly language programming should be fun. That's why I do it.

TimoVJL

MS example
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <commctrl.h>

#pragma comment(lib, "comctl32.lib")

void __cdecl WinMainCRTStartup(void)
{

     HINSTANCE hInst = GetModuleHandle(NULL);
    int nButtonPressed                  = 0;
    TASKDIALOGCONFIG config             = {0};
    const TASKDIALOG_BUTTON buttons[]   = {
                                            { IDOK, L"Change password" }
                                          };
    config.cbSize                       = sizeof(config);
    config.hInstance                    = hInst;
    config.dwCommonButtons              = TDCBF_CANCEL_BUTTON;
    config.pszMainIcon                  = TD_WARNING_ICON;
    config.pszMainInstruction           = L"Change Password";
    config.pszContent                   = L"Remember your changed password.";
    config.pButtons                     = buttons;
    config.cButtons                     = ARRAYSIZE(buttons);

    TaskDialogIndirect(&config, &nButtonPressed, NULL, NULL);
    switch (nButtonPressed)
    {
        case IDOK:
            break; // the user pressed button 0 (change password).
        case IDCANCEL:
            break; // user canceled the dialog
        default:
            break; // should never happen
    }
   
    ExitProcess(0);
}

Minimal manifest for that MS example
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level='asInvoker' uiAccess='false' />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='Win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*' />
    </dependentAssembly>
  </dependency>
</assembly>


May the source be with you

NoCforMe

I don't get it.
It's a dialog. Big deal. What's so special about it?
Is it just a way of creating a dialog programmatically, without using a resource editor?

You know, Timo, your "drive-by" style of posting is quite annoying:
You post code (and of course, almost always in C, hardly ever in assembly language), but with absolutely no explanation.
Not helpful.
Assembly language programming should be fun. That's why I do it.

sinsi

Quote from: NoCforMe on April 10, 2025, 09:53:13 AMIt's a dialog. Big deal. What's so special about it?
It seems to be a standard Windows MessageBox, but with a lot more that you can do (custom buttons etc,).
How many times have you wished for more than Yes, No, Cancel buttons?

NoCforMe

Quote from: sinsi on April 10, 2025, 10:45:52 AM
Quote from: NoCforMe on April 10, 2025, 09:53:13 AMIt's a dialog. Big deal. What's so special about it?
It seems to be a standard Windows MessageBox, but with a lot more that you can do (custom buttons etc,).
How many times have you wished for more than Yes, No, Cancel buttons?
True, but when I wish for that, I simply create the dialog I want (using my DialogGen app).
Takes maybe 5-10 min.
Assembly language programming should be fun. That's why I do it.

zedd151

When I need more than an "OK" button I'd choose a quick and easy resource dialog box. Especially if many controls are needed. Guga can you post a screenshot of what you have in mind?

BobC

#7
Here's another TaskDialog example. I have a few of them in an option trading program I wrote because Excel and some commercial apps could not do the analysis I wanted.

// Warn the user that if the Closed flag is set,
// the current value will be set to 0 and the account
// will be marked as Exclude From Account Totals
int iFlag = theApp.m_oDataSettings.GetDialogFlagsBit(BITPOS_ACCOUNT_CLOSED);
if(iFlag == 0 && m_bClosed)
{
    CXTPTaskDialog dlg(this);
    // See TaskMessages.xml (IDR_DIALOGS) in the HTML resources for the dialog contents
    VERIFY(dlg.CreateFromResource(IDR_DIALOGS, L"DlgAccountClosedWarning"));
    dlg.SetWidth(310);        // #TaskDialog-width find a way to calculate this
    dlg.SetMainInstruction(L"Closing an Account Affects Some Values");
    dlg.SetContent(L"When an account is closed, the current value is set to 0 and 'Exclude Account from Totals' is set.\r\nIf this is acceptable, click OK, else click Cancel and do not close the account.");
    dlg.SetVerificationText(L"Do not show this again.");
    dlg.SetVerifyCheckState(FALSE);    // FALSE = the checkbox gets displayed as unchecked
    dlg.SetCommonButtons(TRUE, FALSE, FALSE, TRUE, FALSE, FALSE);    // the booleans correspond to IDOK, IDYES, IDNO, IDCANCEL, IDRETRY, and IDCLOSE
    dlg.SetDefaultButton(IDCANCEL);
    INT_PTR iResult = dlg.DoModal();
    if(iResult == IDCANCEL)
    {
        return;
    }

    BOOL bDoNotShow = dlg.IsVerificiationChecked();
    theApp.m_oDataSettings.SetDialogFlagsBit(BITPOS_ACCOUNT_CLOSED, bDoNotShow ? BITPOS_SET : BITPOS_CLEAR);
    CNotification oNotify(SENDER_TRADES_VIEW, RM_Settings_Changed, NULL, NULL);
    theApp.m_oData.GetFrameWnd()->NotifySubscribers(oNotify);

    // The user still wants to close the account,
    // so set the current value to 0 and set Exclude Account from Totals to true.
    m_sCurrentValue = "0.00";
    m_bExcludeFromTotals = true;
}

Any result that has to be remembered, such as "Do not show me this again", is saved in a PostgreSQL database.

The dialog XML in resources looks like this:

  <Dialog Name="DlgAccountClosedWarning">
    <WindowTitle>Close Account is selected</WindowTitle>
    <MainInstruction Image="*Information">msg</MainInstruction>
    <Verification Checked="true">Don't show this again</Verification>
    <Buttons>
      <OK/>
    </Buttons>
  </Dialog>

This program is (obviously) in C++ now, but I have considered rewriting it in an assembly language just to get back into it.

guga

Quote from: zedd151 on April 10, 2025, 11:28:18 AMWhen I need more than an "OK" button I'd choose a quick and easy resource dialog box. Especially if many controls are needed. Guga can you post a screenshot of what you have in mind?

Hi Zedd, I wasn't thinking about anything specific. I found these links and this "new" class while I was looking for a way to fix a problem in a RosAsm TAB control. I was looking for ways to change the color of a Tab control's header, without having to use subclasses, and I accidentally found these links that seemed interesting to me, especially these examples in VB6. I'm trying to fix a Tab and make it have colors in the header, but I'm not getting it. And worse, since the SysTabControl is in a dialog box, if I use TCS_OWNERDRAWFIXED, it deletes the icons and texts and I would have to redraw them.

Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

guga

This class seems interesting, though. But, it seems it is mandatory to use manifest, right Timo ? The examples on the VB6 link are really cool, btw. Perhaps it would be interesting to port to asm eventually.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

TimoVJL

Quote from: guga on April 10, 2025, 12:32:28 PMThis class seems interesting, though. But, it seems it is mandatory to use manifest, right Timo ? The examples on the VB6 link are really cool, btw. Perhaps it would be interesting to port to asm eventually.
At least Windows 7 needs that manifest for commctrl 6.0, but not sure about Windows 10
May the source be with you

NoCforMe

Quote from: guga on April 10, 2025, 12:32:28 PMThis class seems interesting, though. But, it seems it is mandatory to use manifest, right Timo ? The examples on the VB6 link are really cool, btw. Perhaps it would be interesting to port to asm eventually.
I can definitely see creating this in assembly language.
If I understand it correctly, the TaskDialogIndirect() function uses the TASKDIALOGCONFIG structure to determine what to put into the dialog.

I'm guessing that while you get to choose what all goes in there, you don't really have any control over the layout. Which is good, from the point of view of the poor slob who's writing this in MASM, because you can just plop controls in preset locations and with preset sizes.

I'm wondering, though: is this really easier than just creating a dialog using the resource editor? That way you get to lay it out so it looks nice and works logically.

Maybe being able to create a dialog with a limited set of choices might be a Good Thing.
And you could probably simplify it a bit: that TASKDIALOGCONFIG structure is pretty horrible.

Plus you wouldn't need no stinkin' manifest ...

Of course, the task dialog function does let you define hyperlinks within the dialog, something that would be a lot of work to implement (I'm guessing).
Assembly language programming should be fun. That's why I do it.

TimoVJL

#12
Quote from: NoCforMe on April 10, 2025, 12:51:22 PMPlus you wouldn't need no stinkin' manifest ...

QuoteMichael Taylor 57,971 Reputation points
Sep 30, 2022, 11:46 PM

It's complicated. The Common Controls library is an OS component. The version you're looking at is the last version (5.82) that was developed before the new CC library came into being. If an app uses the CC library then this is the version it'll get.

However starting with v6 it is now a side-by-side binary. Therefore the actual file resides under the WinSxS folder. If an app needs to use the v6+ version then it must have an app manifest. That is discussed here. If an app uses a manifest then ultimately it will use the SxS version in this folder. If there is no manifest then it is pre-6 and uses the last version which is 5.82.

If you do a quick search for the binary then you'll see that the latest current version appears to be 10.0.22000.1 but that can change and it doesn't really matter unless your app manifest references that version anyway. You should always use the minimal version that your app requires.
https://learn.microsoft.com/en-us/answers/questions/1031264/what-is-the-latest-version-of-windows-os-file-comc

linker can write external manifest, if source file have this
.drectve SEGMENT
db "-manifestdependency:""type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'"""
.drectve ENDS
newer linker can create resource section too
.drectve SEGMENT
db "-manifest:embed -manifestdependency:""type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'"""
.drectve SEGMENT
May the source be with you

NoCforMe

What the hell are you going on about?
I obviously meant you wouldn't need no stinkin' manifest if you wrote your own "task dialog" procedure (in assembly language, naturally).
Assembly language programming should be fun. That's why I do it.

guga

Quote from: NoCforMe on April 10, 2025, 12:51:22 PM
Quote from: guga on April 10, 2025, 12:32:28 PMThis class seems interesting, though. But, it seems it is mandatory to use manifest, right Timo ? The examples on the VB6 link are really cool, btw. Perhaps it would be interesting to port to asm eventually.
I can definitely see creating this in assembly language.
If I understand it correctly, the TaskDialogIndirect() function uses the TASKDIALOGCONFIG structure to determine what to put into the dialog.

I'm guessing that while you get to choose what all goes in there, you don't really have any control over the layout. Which is good, from the point of view of the poor slob who's writing this in MASM, because you can just plop controls in preset locations and with preset sizes.

I'm wondering, though: is this really easier than just creating a dialog using the resource editor? That way you get to lay it out so it looks nice and works logically.

Maybe being able to create a dialog with a limited set of choices might be a Good Thing.
And you could probably simplify it a bit: that TASKDIALOGCONFIG structure is pretty horrible.

Plus you wouldn't need no stinkin' manifest ...

Of course, the task dialog function does let you define hyperlinks within the dialog, something that would be a lot of work to implement (I'm guessing).

I was reading this structure and indeed, it is horrible. For what i saw so far, as Timo pointed out, it do, in fact, needs this manifest thing. The exported function does not exists on normal comctl32 dll (syswow64 directory), but on newer versions located deep inside some weird paths of windows 10.

I´ll never understand why M$ do such stupidities. Why the hell they put an older version of comclt32 in the default system directory at the 1st place ? The least they could do is put all those newer versions on the default windows system paths.

QuoteI'm wondering, though: is this really easier than just creating a dialog using the resource editor
Probably not, i was mainly wanting to give a try after i saw the images of the results on the VB6 forum, but without ways for me to use those manifest resources, i´ll have to work with this later.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com