April 25, 2024, 10:04:42 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


How to start Dialog prog Hidden/displayed

Started by Allan, August 28, 2008, 08:43:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Allan

I am working on an application that has two different possibilites when it starts.

1. I want the program to run but not display the dialog window.
2. I want the program to run and display the dialog window.

I find that I have to use SHOWDIALOG d1 to get the IDINITDIALOG Messager handled.

The code below shows that I need the INITDIALOG to set up some stuff.

If I delimiter out SHOWDIALOG d1 then it will not go into the IDINITDIALOG and do the setups.

CONST BUTTON_1 = 1
DIALOG d1
CREATEDIALOG d1,0,0,300,202,0x80C80080,0,"Caption",&d1_handler
CONTROL d1,@BUTTON,"Button1",104,66,70,20,0x50000000,BUTTON_1

MESSAGEBOX 0, "Before SHOWDIALOG","INFO"
SHOWDIALOG d1
'SHOWWINDOW d1, @SWHIDE
MESSAGEBOX 0, "After SHOWDIALOG","INFO"
'SHOWWINDOW d1, @SWRESTORE

WAITUNTIL d1 = 0
END

SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
MESSAGEBOX 0, "In IDINITDIALOG","INFO"
CENTERWINDOW d1
/* Initialize any controls here */
' Setupd1()
' db = OpenDatabase()
' SetupListView()
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
/*button clicked*/
ENDIF
ENDSELECT
ENDSELECT
RETURN
ENDSUB


Any work arounds please?

Ionic Wind Support Team

Not sure I am following you.  What is it exactly that isn't working?

SHOWDIALOG will return almost immediately after Windows creates the dialog and controls. The dialog and controls don't exist at all until either ShowDialog or DoModal is called.

CreateDialog creates a template in memory which control definitions are added to.  It is not like OpenWindow which does the creating of the window immediately.

When it is safe to access the dialog and controls Windows sends the @IDINITDIALOG message.  Trying to do anything to the dialog before @IDINITDIALOG is received won't work because the dialog isn't there yet.  And the entire purpose of the Microsoft designed scheme is reusability.  Once the template has been created with CreateDialog and controls added to the template with the Control statement, then the dialog can be reshown over and over again by calling DoModal, or ShowDialog as the case may be.

If you want to hide the dialog on creation you have to do it in @IDINITDIALOG

Paul.
Ionic Wind Support Team

Allan

Ok - thank you very much for the explanation on how the Dialogs work.

Nothing is broken, just could not get it to do what it cannot do.

I had it in my head that SHOWDIALOG made it work LIKE a WINDOW.  (Not so)

QuoteIf you want to hide the dialog on creation you have to do it in @IDINITDIALOG

I would have to DOMODAL or SHOWDIALOG to get into the IDINITDIALOG  so as to HIDE the Dialog which would defeat the idea as the Dialog would display briefly.

I am using the program with a database and if there are entries in a certain category I will not display the window but put an ICON in the SysTray from which I can then display or close the dialog. Else if NO entries then the program will just close itself down.

Looks like from your answer I should use WINDOW.


Ionic Wind Support Team

The purpose of ShowDialog is to have a non-modal dialog in a program.  One that doesn't block user input to other windows/dialogs in the program.

I'll add it to my todo list to support the new @hidden style for dialogs too. 

Paul.
Ionic Wind Support Team

Allan

Like a Find or Find/Replace dialog ....

I saw ShowDialog in the Address Book Database example and tried using it that way as a main window.

LarryMc

Will something like this work for you?

'main program


init_d1()

blah blah.....
check_ d1()
blah blah.....
check_ d1()

end

sub init_d1()
CREATEDIALOG d1,0,0,300,202,0x80C80080,0,"Caption",&d1_handler
CONTROL d1,@BUTTON,"Button1",104,66,70,20,0x50000000,BUTTON_1
return
endsub

sub check_d1()
   if this and that
/* Initialize any controls here */
' Setupd1()
' db = OpenDatabase()
' SetupListView()
      showdialog d1
  else
      do something else
  endif
return
endsub


SUB d1_handler
   SELECT @MESSAGE
      CASE @IDINITDIALOG
CENTERWINDOW d1
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
/*button clicked*/
ENDIF
ENDSELECT
ENDSELECT
RETURN
ENDSUB


Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Allan

Thanks Larry.

But I dont think that would work as you have to DISPLAY the dialog to get the IDINITDIALOG to get access.

You could not work at setting up the ListView unless the Dialog existed.

QuoteThe dialog and controls don't exist at all until either ShowDialog or DoModal is called.

It has to be set up in case I decide to display the Dialog, even if I have originally had it hidden.

LarryMc

I misunderstood.

Yep, a window is the way to go.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

mrainey

Couldn't you create the dialog visible but offscreen and use SETSIZE to position it onscreen when called for?  I do this often with windows and controls.
Software For Metalworking
http://closetolerancesoftware.com

sapero

August 29, 2008, 09:21:04 AM #9 Last Edit: October 22, 2008, 01:27:46 PM by sapero
A trick with WM_WINDOWPOSCHANGING:
$include "windowssdk.inc"
DIALOG d1
CREATEDIALOG d1,0,0,300,202,0x80C80880,0,"Caption",&d1_handler
SHOWDIALOG d1

while d1.hwnd
wait
endwhile

int g_showme

sub d1_handler

select @MESSAGE

case @IDINITDIALOG
'MESSAGEBOX 0, "after you click OK, dialog will be not visible for 2s", ""
g_showme = false
STARTTIMER d1, 2000

case WM_WINDOWPOSCHANGING
if (g_showme = 0) then _
*<WINDOWPOS>@LPARAM.flags &= (0xffffffff - SWP_SHOWWINDOW)

case @IDTIMER
g_showme = true
SHOWWINDOW d1, @SWRESTORE

CASE @IDCLOSEWINDOW
CLOSEDIALOG d1
ENDSELECT
RETURN
ENDSUB



LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Allan

QuoteCouldn't you create the dialog visible but offscreen and use SETSIZE to position it onscreen when called for?  I do this often with windows and controls.

I could try that.

I had tried setting it off screen. but it seems to appear top left corner when ShowDialog is used to have the IDINITDIALOG work.
Putting SHOWWINDOW d1, @SWHIDE in the IDINITDIALOG does hide it though. ALAS but it does show briefly before hiding!

I converted it to a windows program and used the new feature @HIDING in the Flags for the Window and it is now doing all that I need!

Just having a small hassle getting the ICON in the SysTray to show (everytime). Does show when double clicked from the Startup folder but not always when booting the system.

Noticed MEMORY var used in some examples of SysTray Icon from old forums - so will try that now!