FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DFL bug report

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
obijohn



Joined: 07 Feb 2006
Posts: 24

PostPosted: Fri Dec 28, 2007 11:00 am    Post subject: DFL bug report Reply with quote

First, let me congratulate Chris on two wonderful packages, DFL and Entice. Really, really nice work!

Ok, the bug report, and it's really odd. I'm using DMD 1.024 and the most recent DFL snapshot of December 6th (which states it was tested with DMD 1.024). Windows XP Pro SP2. The bug has to do with the fact that when a menu is defined, the "Alt"-shortcut doesn't always work. It only seems to work if a control on the Main Form has focus.

Also, let me clarify what I mean by the "Alt"-shortcut. When a menu is defined, if the text is set to "&File", then the "F" is underlined when the menu is displayed and the menu now has a shortcut, so that pressing "Alt+F" will open the menu. The bug I'm reporting is that when a control doesn't have focus in the Main Form, pressing "Alt+F" will not bring up this example "File" menu (however, pressing "Alt" by itself and then releasing it will still highlight the menu bar, so that pressing "F" by itself after pressing and releasing the "Alt" key will open the "File" menu). If a control on the Main Form does have focus, pressing "Alt+F" will open the "File" menu. Whether a control has focus or not shouldn't matter because "Alt+F" should always open the "File" menu if the Main Form itself has focus, just as pressing and releasing "Alt" by itself always highlights the menubar.

The following code adds a simple menu to a Main Form created in Entice, with no other controls, and pressing "ALT+F" does not bring up the "File" menu since there is no control on the form with focus (but pressing and releasing the "Alt" key by itself will highlight the menubar so that then pressing "F" will open the menu). The "Ctrl+Q" shortcut added to the code still works and is not affected by the bug.

Code:

/*
   Generated by Entice Designer
   Entice Designer written by Christopher E. Miller
   www.dprogramming.com/entice.php
*/

private import dfl.all;


class MainForm: dfl.form.Form
{
   // Do not modify or move this block of variables.
   //~Entice Designer variables begin here.
   //~Entice Designer variables end here.
 
   this()
   {
      initializeMainForm();
      
      //@  Other MainForm initialization code here.
      
      menu = new MainMenu;
      MenuItem mpop, mi;      
      with(mpop = new MenuItem)
      {
         text = "&File";
         index = 0;
         menu.menuItems.add(mpop);
      }            
      with(mi = new MenuItem)
      {
         text = "&Quit\tCtrl+Q";
         index = 0;
         mpop.menuItems.add(mi);         
         click ~= &file_exit_click;
      }
      addShortcut(Keys.CONTROL | Keys.Q, &file_exit_click);
      
   }
   
   private void file_exit_click(Object obj, EventArgs args)
   {
      Application.exitThread;
   }
       
   private void initializeMainForm()
   {
      // Do not manually modify this function.
      //~Entice Designer 0.8.4 code begins here.
      //~DFL Form
      text = "Main Form";
      clientSize = dfl.all.Size(328, 270);
      //~Entice Designer 0.8.4 code ends here.
   }
}


int main()
{
   int result = 0;
   
   try
   {
      Application.enableVisualStyles();
      
      //@  Other application initialization code here.
      
      Application.run(new MainForm());
   }
   catch(Object o)
   {
      msgBox(o.toString(), "Fatal Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR);
      
      result = 1;
   }
   
   return result;
}



Adding a Tab Control to the Main From doesn't help -- "ALT+F" still doesn't bring up the menu, again because no control has focus since a Tab Control can't receive focus itself:
Code:

/*
   Generated by Entice Designer
   Entice Designer written by Christopher E. Miller
   www.dprogramming.com/entice.php
*/

private import dfl.all;


class MainForm: dfl.form.Form
{
   // Do not modify or move this block of variables.
   //~Entice Designer variables begin here.
   dfl.tabcontrol.TabControl tabControl1;
   //~Entice Designer variables end here.
 
   this()
   {
      initializeMainForm();
      
      //@  Other MainForm initialization code here.
      
      menu = new MainMenu;
      MenuItem mpop, mi;      
      with(mpop = new MenuItem)
      {
         text = "&File";
         index = 0;
         menu.menuItems.add(mpop);
      }            
      with(mi = new MenuItem)
      {
         text = "&Quit\tCtrl+Q";
         index = 0;
         mpop.menuItems.add(mi);         
         click ~= &file_exit_click;
      }
      addShortcut(Keys.CONTROL | Keys.Q, &file_exit_click);
      
   }
   
   private void file_exit_click(Object obj, EventArgs args)
   {
      Application.exitThread;
   }
       
   private void initializeMainForm()
   {
      // Do not manually modify this function.
      //~Entice Designer 0.8.4 code begins here.
      //~DFL Form
      text = "Main Form";
      clientSize = dfl.all.Size(328, 270);
      //~DFL dfl.tabcontrol.TabControl=tabControl1
      tabControl1 = new dfl.tabcontrol.TabControl();
      tabControl1.name = "tabControl1";
      tabControl1.bounds = dfl.all.Rect(0, 16, 328, 200);
      tabControl1.parent = this;
      //~Entice Designer 0.8.4 code ends here.
   }
}


int main()
{
   int result = 0;
   
   try
   {
      Application.enableVisualStyles();
      
      //@  Other application initialization code here.
      
      Application.run(new MainForm());
   }
   catch(Object o)
   {
      msgBox(o.toString(), "Fatal Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR);
      
      result = 1;
   }
   
   return result;
}


Adding a Button beneath the Tab Control still doesn't work, again because it doesn't have focus, although why it doesn't is a mystery to me -- if a Tab Control can't receive focus, it seems logical that default focus should be given to some control which can receive focus. Note that if you're trying to re-create this in Entice, the order the code appears in initializeMainForm() is important: if the button is initialized before the Tab Control, it will get default focus, but not if it's initialized after the Tab Control. And this order depends entirely on Entice, since it is automatically generated and edits are lost once Entice rewrites the code. For instance, after adding the button and saving the code, if you move the button Entice will sometimes re-order its initialization code to appear before the Tab Control initialization.

Code:

/*
   Generated by Entice Designer
   Entice Designer written by Christopher E. Miller
   www.dprogramming.com/entice.php
*/

private import dfl.all;


class MainForm: dfl.form.Form
{
   // Do not modify or move this block of variables.
   //~Entice Designer variables begin here.
   dfl.tabcontrol.TabControl tabControl1;
   dfl.button.Button yoButton;
   //~Entice Designer variables end here.
 
   this()
   {
      initializeMainForm();
      
      //@  Other MainForm initialization code here.
      
      menu = new MainMenu;
      MenuItem mpop, mi;      
      with(mpop = new MenuItem)
      {
         text = "&File";
         index = 0;
         menu.menuItems.add(mpop);
      }            
      with(mi = new MenuItem)
      {
         text = "&Quit\tCtrl+Q";
         index = 0;
         mpop.menuItems.add(mi);         
         click ~= &file_exit_click;
      }
      addShortcut(Keys.CONTROL | Keys.Q, &file_exit_click);
      
   }
   
   private void file_exit_click(Object obj, EventArgs args)
   {
      Application.exitThread;
   }
       
   private void initializeMainForm()
   {
      // Do not manually modify this function.
      //~Entice Designer 0.8.4 code begins here.
      //~DFL Form
      text = "Main Form";
      clientSize = dfl.all.Size(328, 270);
      //~DFL dfl.tabcontrol.TabControl=tabControl1
      tabControl1 = new dfl.tabcontrol.TabControl();
      tabControl1.name = "tabControl1";
      tabControl1.bounds = dfl.all.Rect(0, 16, 328, 200);
      tabControl1.parent = this;
      //~DFL dfl.button.Button=yoButton
      yoButton = new dfl.button.Button();
      yoButton.name = "yoButton";
      yoButton.text = "Yo";
      yoButton.bounds = dfl.all.Rect(128, 232, 75, 23);
      yoButton.parent = this;
      //~Entice Designer 0.8.4 code ends here.
   }
}


int main()
{
   int result = 0;
   
   try
   {
      Application.enableVisualStyles();
      
      //@  Other application initialization code here.
      
      Application.run(new MainForm());
   }
   catch(Object o)
   {
      msgBox(o.toString(), "Fatal Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR);
      
      result = 1;
   }
   
   return result;
}



If you click on the button after the form is displayed, it will receive focus and the "Alt"-shortcuts will then work. Also, adding a yoButton.focus() or yoButton.select() to the user-initialization code in the MainForm constructor (marked by a bookmark in Entice) doesn't work, although I believe it's supposed to.

The app I'm working on right now has lots of controls contained in tab pages. The only thing on my Main Form is a menu and a Tab Control -- and the "Alt"-shorcuts don't work for the menus because a control on the Main From can't get focus (because all the controls are in tab pages, not on the Main Form).

Well, I know I went into a lot of detail, probably too much, but I wanted to be as specific as I could about what was happening.
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Sat Jan 19, 2008 4:54 pm    Post subject: Re: DFL bug report Reply with quote

Thanks for reporting this, but I can't seem to fix it. I just spent a few hours trying to track it down without any luck.

I did find this out: not calling IsDialogMessage (winapi) causes the menu mnemonics to work but not the control ones; calling it causes the reverse. I would appreciate any assistance. It can involve any of the following windows API keywords: IsDialogMessage, DefDlgProc, DefWindowProc, WM_GETDLGCODE, WM_SYSKEYDOWN, WM_MENUSELECT, WM_INITMENU, WM_INITMENUPOPUP.
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Mon Feb 18, 2008 2:40 am    Post subject: Re: DFL bug report Reply with quote

Update: current snapshot has a fix for this.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group