Recent

Author Topic: [SOLVED] TTaskdialog -> console app : error 1407  (Read 3176 times)

scons

  • Full Member
  • ***
  • Posts: 141
[SOLVED] TTaskdialog -> console app : error 1407
« on: June 20, 2018, 06:45:27 pm »
Hi all,

I was thinking to create a little application that calls the TTaskdialog. It might seem foolish doing it like this but the objective was to send the command + parameters from another program, then write the output to a file, file back into other program, done.

First test crashes with error:
Code: Text  [Select][+][-]
  1. Failed to create win32 control, error 1407
So it needs a windows something ??

This is my initial setup (I might be totally wrong too about this)

Code: Pascal  [Select][+][-]
  1. program msgdlg2;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   Classes,
  7.   SysUtils,
  8.   Dialogs,
  9.   Interfaces,
  10.   Windows,
  11.   CustApp,
  12.   Messages,
  13.   Forms,
  14.   Controls,
  15.   Graphics;
  16.  
  17. type
  18.   { TCreateMsgDlgApplication }
  19.  
  20.   TCreateMsgDlgApplication = class(TCustomApplication)
  21.   public
  22.     procedure Run;
  23.   end;
  24.  
  25.   { TCreateMsgDlgApplication }
  26.  
  27.   procedure TCreateMsgDlgApplication.Run;
  28.   var
  29.     TaskDialog: TTaskDialog;
  30.     Button: TTaskDialogBaseButtonItem;
  31.   begin
  32.     with TTaskDialog.Create(self) do
  33.       try
  34.         Title := 'Confirm removal';
  35.         Caption := 'Confirm';
  36.         Text := 'Remove selected item?';
  37.         CommonButtons := [];
  38.         with TTaskDialogButtonItem(Buttons.Add) do
  39.         begin
  40.           Caption := 'Remove';
  41.           ModalResult := mrYes;
  42.         end;
  43.         with TTaskDialogButtonItem(Buttons.Add) do
  44.         begin
  45.           Caption := 'Keep';
  46.           ModalResult := mrNo;
  47.         end;
  48.         MainIcon := tdiQuestion;
  49.         if Execute then
  50.           if ModalResult = mrYes then
  51.             ShowMessage('Item removed');
  52.       finally
  53.         Free;
  54.       end;
  55.   end;
  56.  
  57. var
  58.   AppDlg: TCreateMsgDlgApplication;
  59. begin
  60.   AppDlg := TCreateMsgDlgApplication.Create(nil);
  61.   AppDlg.Run;
  62.   AppDlg.Free;
  63. end.

Do I need to include something else or am I totally going in the wrong direction ?

Project in attached.
« Last Edit: June 20, 2018, 10:42:35 pm by scons »
Windows 10-64bit Lazarus 2.0.12 + FPC 3.2.0

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: TTaskdialog -> console app : error 1407
« Reply #1 on: June 20, 2018, 07:23:05 pm »
You need to initialize the widgetset before you can use that.
And yes, I know it is not Delphi compatible.

Bart

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1312
    • Lebeau Software
Re: TTaskdialog -> console app : error 1407
« Reply #2 on: June 20, 2018, 07:58:31 pm »
First test crashes with error:
Code: Text  [Select][+][-]
  1. Failed to create win32 control, error 1407
So it needs a windows something ??

Win32 error 1407 is ERROR_CANNOT_FIND_WND_CLASS, which means the task dialog's window class hasn't been registered.

Task Dialogs require ComCtrl32.dll v6, so make sure your EXE is adequately manifested to enable that (see Enabling Visual Styles on MSDN).  And make sure your app is calling InitCommonControls/Ex() at runtime, either directly or via some FreePascal widget unit that handles that for you.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

scons

  • Full Member
  • ***
  • Posts: 141
Re: TTaskdialog -> console app : error 1407
« Reply #3 on: June 20, 2018, 10:42:10 pm »
Thanks for your responses, got me thinking,

Menu : Project -> Project Options ->Application -> For Windows -> enabeling the checkbox "Use manifest resource (and enable themes)"
did the trick no error, runs fine.


Thanks !
Windows 10-64bit Lazarus 2.0.12 + FPC 3.2.0

 

TinyPortal © 2005-2018