lsp doesnt work when dialog called from another dialog

Started by andrew, February 09, 2010, 12:29:27 PM

Previous topic - Next topic

owenwengerd

Owen Wengerd (Outside The Box) / ManuSoft

andrew

i understood that, but closing the modal form to allow for selecting still didnt work.

this is frustrating... :-\

Fred Tomke

#17
Hello, andrew,

I attached a completely rewritten code. Check it out. It works quite well for me.
Have a closer look at this topic.

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

andrew

#18
Hi Fred,
thanks for your reply
im checking out that link you posted now

i tested your modification to the code and after i close the search dialog i notice it still leaves me in the command (somewhat) what i mean is it doesnt leave me at a command  prompt it still looks like im in the selection command.

also i noticed in the code you used
(dcl_Form_Close STKBK_stockbook 3)

similar to what Owen has suggested
what does the 3 mean
1 and 2 is explained in the helps but i didnt see 3

if i were to change the 3 to a 1 would that exit me out of the while loop when i press enter?

thanks again for your assistance

also
i noticed that after i press enter and it reinitializes the stock book
this line
(dcl_Control_SetText STKBK_stockbook_TextBox1 "")
which is supposed to clear the search entry on initialize doesnt clear it

Fred Tomke

#19
Hi, andrew,

Quote from: andrew on February 18, 2010, 06:03:07 AM
i tested your modification to the code and after i close the search dialog i notice it still leaves me in the command (somewhat) what i mean is it doesnt leave me at a command  prompt it still looks like im in the selection command.

Yes, that's right. It's because the subform is starting from an event calling by a control which property EventInvoke was set to KeepFocus.
That's a real mess of this code: there is an OnClick event. During the OnClick event the form shall be closed and another form shall be shown with the option to have access to AutoCAD. That's not good. It is even very bad - especially for having access to AutoCAD. Because you try to get access to AutoCAD while still a OnClick-event from the initial form is still running! Although you don't expect this and you think the OnClick event of the initial form is already over. That's why the entmod line didn't work and I changed it to do it via ActiveX to make it work.
The reason is the modeless form the subform is starting from. It would be easier to make it work from a modal form but I'm afraid that this is a part of a bigger project and you try to start it from a modeless form/palette/dockable form.

So, to solve this, it would need another reconstruction: the subform should be started from a asynchronous called command using dcl_sendstring.

Quote from: andrew on February 18, 2010, 06:03:07 AM
(dcl_Form_Close STKBK_stockbook 3)
what does the 3 mean
1 and 2 is explained in the helps but i didnt see 3

That's right. You cannot see 3 in the help because 3 was my own choice  ;) . These values mentioned in the help are reserved values. That means, you can use your own values greater than 2 for additional reasons.

Quote from: andrew on February 18, 2010, 06:03:07 AM
if i were to change the 3 to a 1 would that exit me out of the while loop when i press enter?

No, that are two different things. I also noticed that the form is being closed after pressing ENTER.
Have a look at the FAQ to solve that.
The value passing dcl_form_close is the returning value given by dcl_form_show to evaluate later.

Quote from: andrew on February 18, 2010, 06:03:07 AM
if i were to change the 3 to a 1 would that exit me out of the while loop when i press enter?

You are right! I must agree with you that Copy&Paste did a better job in the past! Have a look in your code. There you can read
Code (autolisp) Select

(defun c:dwgbrowser_stockbook_OnInitialize (/)
  (dcl_Control_SetText STKBK_stockbook_TextBox1 "")
); c:dwgbrowser_stockbook_OnInitialize


What do you mean? Wouldn't it work better if you use instead

Code (autolisp) Select

(defun c:STKBK_stockbook_OnInitialize (/)
  (dcl_Control_SetText STKBK_stockbook_TextBox1 "")
); c:STKBK_stockbook_OnInitialize


Just kidding  :D I've overseen it, too.

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

andrew

Quote from: Fred Tomke on February 18, 2010, 07:10:40 AM

So, to solve this, it would need another reconstruction

you are just filled with good news  :'(


Quote
You are right! I must agree with you that Copy&Paste did a better job in the past! Have a look in your code. There you can read
Code (autolisp) Select

(defun c:dwgbrowser_stockbook_OnInitialize (/)
  (dcl_Control_SetText STKBK_stockbook_TextBox1 "")
); c:dwgbrowser_stockbook_OnInitialize


What do you mean? Wouldn't it work better if you use instead

Code (autolisp) Select

(defun c:STKBK_stockbook_OnInitialize (/)
  (dcl_Control_SetText STKBK_stockbook_TextBox1 "")
); c:STKBK_stockbook_OnInitialize


Just kidding  :D I've overseen it, too.

Fred

wow im blind...

i have a bit more reading to do before i can continue with this project

Fred thank you for your explaination on things

Fred Tomke

Hi, andrew,

Quoteyou are just filled with good news

That's why I call myself Mr. Bad Guy  :P

No, seriously, I thought about changing your project again, but this evening I had a meeting with a friend. And now I have a meeting with my wife. Sorry. But will have a closer look when I find the time in the next days.

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Fred Tomke

Hi, andrew,

and here it is:


  • I've given you two wys to start the subform. Compare EventInvoke property of both the buttons and the event handler names they call in the event tab.
  • Please prefer the second way (button).
  • I've created a new command for the subform. This command is called by both of the buttons.
  • That's why you can repeat this command by pressing enter after closing the subform.
  • If the main form is active on screen, it will be set hidden for the time the subform command is running. Don't forget to make it visible after each subform command.
  • The list will be filled initially with all the items of the txt file. Then the user can filter it by typing a search string.
  • I've added the OnCancelClose event to make sure pressing enter in the textbox will invoke a new search.
  • I prefer to see the same when the subform comes up as I left it before. So it's a good design to keep the last search.
  • I've added a Clear button to clear the last search.
  • When double clicking a listbox item the text objects are changed using entmod instead of ActiveX again.

I hope that I didn't miss anything!
May I use this sample for my FAQ about closing and reshowing forms?
As you can see the way to do this from modal forms is quite different to modeless forms.

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

andrew

#23
Hi Fred,

WOW you have re-written the code alot heh
i wasnt expecting that, but thanks.

im still reading over the links you posted
to get a better understanding of how this works.

this code is or was however a subroutine of a larger code
which was broken down to its own for the purpose of debugging
the main code which this routine will be called from is a modeless form
so i guess this will work?

after i ran your code i get an error

NIL value not allowed
function: dcl_control_setvisible
argument: 0

when i click "ok" the program starts up

please feel free to use this for your FAQ im sure there will be some beginner out there who can benifit from this.

thanks

all is good Fred, i restarted acad and its working now

owenwengerd

Andrew:

Please don't edit your posts to add a followup comment -- just post a new message instead. I can figure out what happened because I saw your original message before you edited it, but someone reading this thread now will be confused by your statement at the end "all is good..." after you just described a problem.
Owen Wengerd (Outside The Box) / ManuSoft

andrew