Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-07

LCL: menu creation order

14 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to Michael Van Canneyt: I did, with todays sources: malpertuus: /cygdrive/e/pp/projects/lazarus/examples…
Michael Van Canneyt wrote 20 lines
> > Ultimate reason: the win32 interface seems to crash when a shortcut is set > > for a particular menuitem. It occurs when running the lazarus ide. > > I'm sure you will find the bug. > > Apropos IDE: Did you try the TSynEdit under win32? I did, with todays sources: malpertuus: /cygdrive/e/pp/projects/lazarus/examples >./edittest [FORMS.PP] ExceptionOccurred Sender=EACCESSVIOLATION Exception=Access violation TApplication.HandleException Access violation TApplication.HandleException Handling "Access violation" ... [FORMS.PP] ExceptionOccurred Not very informative :-/

Follow-up:

Executing progressbar (or any other) example,
I get zillions of these messages:

Exception=Unknown Run-Time error : 217
TApplication.HandleException: there was another exception during showing the first exception [FORMS.PP] ExceptionOccurred
Sender=EXCEPTION
Exception=Unknown Run-Time error : 217

So something is definitely wrong in the windows interface:/

Michael.

Reply by email

Mattias Gaertner
to Micha Nelissen: Currently, TMenuItem.CreateHandle looks like this: --- SendMsgToInterface(LM_CREATE,…
Show quoted text 24 lines
Hi, Currently, TMenuItem.CreateHandle looks like this: --- SendMsgToInterface(LM_CREATE, Self, nil); if FItemsnil then begin for i := 0 to Count - 1 do begin Items[i].HandleNeeded; end; end; if Parent nil then begin Parent.HandleNeeded; if Parent.HandleAllocated then SendMsgToInterface(LM_ATTACHMENU, Self, nil); if HandleAllocated then begin if ShortCut 0 then ShortCutChanged(0, Shortcut); end; end; --- It first creates the children, then attaches to parent. Wouldn't it be more logical to do it the other way around?

Bottom-Up or Top-Down are both logical and should be supported by the interfaces. But for readability and debugging I changed it.

First check/attach parent, then create children? I am asking this because win32object.attachmenu uses the parent of the parent and I am not sure whether it is initialized at all times, ie. the children are attached to parents.

What do you need to fix that?

Ultimate reason: the win32 interface seems to crash when a shortcut is set for a particular menuitem. It occurs when running the lazarus ide.

I'm sure you will find the bug.

Apropos IDE: Did you try the TSynEdit under win32?

Mattias

Reply by email

Michael Van Canneyt
to Mattias Gaertner
Show quoted text 6 lines
> Ultimate reason: the win32 interface seems to crash when a shortcut is set > for a particular menuitem. It occurs when running the lazarus ide. I'm sure you will find the bug. Apropos IDE: Did you try the TSynEdit under win32?

I did, with todays sources:

malpertuus: /cygdrive/e/pp/projects/lazarus/examples >./edittest [FORMS.PP] ExceptionOccurred
Sender=EACCESSVIOLATION
Exception=Access violation
TApplication.HandleException Access violation
TApplication.HandleException Handling "Access violation" ... [FORMS.PP] ExceptionOccurred

Not very informative :-/

Michael.

Reply by email

Micha Nelissen

Hi,

Currently, TMenuItem.CreateHandle looks like this:

---
  SendMsgToInterface(LM_CREATE, Self, nil);
  if FItemsnil then begin
    for i := 0 to Count - 1 do begin
      Items[i].HandleNeeded;
    end;
  end;
  if Parent  nil then
  begin
    Parent.HandleNeeded;
    if Parent.HandleAllocated then
      SendMsgToInterface(LM_ATTACHMENU, Self, nil);
    if HandleAllocated then begin
      if ShortCut  0 then ShortCutChanged(0, Shortcut);
    end;
  end;
---

It first creates the children, then attaches to parent. Wouldn't it be more logical to do it the other way around? First check/attach parent, then create children? I am asking this because win32object.attachmenu uses the parent of the parent and I am not sure whether it is initialized at all times, ie. the children are attached to parents.

Ultimate reason: the win32 interface seems to crash when a shortcut is set for a particular menuitem. It occurs when running the lazarus ide.

Thanks,

Micha.

Reply by email

Micha Nelissen
to Micha Nelissen
Mattias Gaertner wrote 9 lines
On Tue, 1 Jul 2003 10:08:38 +0200 "Micha Nelissen" wrote: > > It first creates the children, then attaches to parent. Wouldn't it > be more logical to do it the other way around? Bottom-Up or Top-Down are both logical and should be supported by the interfaces. But for readability and debugging I changed it.

Seems reasonable.

Show quoted text 7 lines
> First check/attach parent, then create children? I am asking this > because win32object.attachmenu uses the parent of the parent and I > am not sure whether it is initialized at all times, ie. the children > are attached to parents. What do you need to fix that?

I am wondering about the following piece of code from win32object.attachmenu:

---
  {Following part fixes the case when an item is added in runtime
  but the parent item has not defined the submenu flag (hSubmenu=0) }
  if (Sender as TMenuItem).Parent.Parentnil then
  begin
    ParentOfParent := (Sender as TMenuItem).Parent.Parent.Handle;
    with MenuInfo do begin
      cbSize:=sizeof(MENUITEMINFO);
      fMask:=MIIM_SUBMENU;
    end;
    GetMenuItemInfo(ParentOfParent, (Sender as TMenuItem).Command,
                    false, @MenuInfo);
    if MenuInfo.hSubmenu=0 then // the parent menu item is not yet defined
with submenu flag
    begin
      MenuInfo.hSubmenu:=ParentMenuHandle;
      SetMenuItemInfo(ParentOfParent, (Sender as TMenuItem).Command,
                      false, MenuInfo);
    end;
  end;
---

It says it fixes something. But:
1) It it retrieves menuitem if parentofparent, it should use it's parent command: (Sender as TMenuItem).Parent.Command.
2) All calls to InsertMenuItem (there is only 1) define menuinfo.hSubMenu := MenuHandle, which is always already created in CreateHandle. If I 'fix' item 1, it never gets to SetMenuItemInfo anymore, supporting this statement.

Any thoughts?

Micha.

Reply by email

Marco van de Voort
to Michael Van Canneyt: Follow-up: Executing progressbar (or any other) example, I get zillions of these messages:
Show quoted text 20 lines
On Tue, 1 Jul 2003, Michael Van Canneyt wrote: > Exception=Access violation > TApplication.HandleException Access violation > TApplication.HandleException Handling "Access violation" ... > [FORMS.PP] ExceptionOccurred > > Not very informative :-/ Follow-up: Executing progressbar (or any other) example, I get zillions of these messages: Exception=Unknown Run-Time error : 217 TApplication.HandleException: there was another exception during showing the first exception [FORMS.PP] ExceptionOccurred Sender=EXCEPTION Exception=Unknown Run-Time error : 217 So something is definitely wrong in the windows interface:/

I also got this already since late last week (wednesday or so)

Reply by email

Micha Nelissen
to Vincent Snijders: Forwarded to the list. -----Oorspronkelijk bericht----- Van: Micha Nelissen Verzonden:…
Mattias Gaertner wrote 13 lines
On Tue, 1 Jul 2003 15:28:55 +0200 "Vincent Snijders" wrote: >> Same here, but the progressbar example has a new bug: When you click >> on toggle smooth, all buttons disappear and only every second a blue >> block is shown. I might have to do something with the changes to the >> code of wm_erasebackground recently. > > I found it! The BeginPaint function is not implemented in > lcl/include/winapi.inc. Can we introduce a method for it in the > interface? Added.

Well, completing the interface implementation does make it all work. I have attached a patch for that. But: it has a gigantic memory leak. If I take the progressbar example and let it fire every 50ms, memory is depleted in 10 seconds. Not good.

Regards,

Micha.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bin00044.bin
Type: application/octet-stream
Size: 3569 bytes
Desc: "beginendpaint.patch"
Url : http://localhost/pipermail/lazarus/attachments/20030701/1c179f44/bin00044.bin

Reply by email

Vincent Snijders

Forwarded to the list.

-----Oorspronkelijk bericht-----
Van: Micha Nelissen
Verzonden: dinsdag 1 juli 2003 15:25
Aan:

Vincent Snijders wrote 50 lines
> Van: Micha Nelissen > Verzonden: dinsdag 1 juli 2003 13:43 > Michael Van Canneyt wrote: >> On Tue, 1 Jul 2003, Michael Van Canneyt wrote: >> >>> >>> >>>>> Ultimate reason: the win32 interface seems to crash when a >>>>> shortcut is set >>>>> for a particular menuitem. It occurs when running the lazarus >>>>> ide. >>>> >>>> I'm sure you will find the bug. >>>> >>>> Apropos IDE: Did you try the TSynEdit under win32? >>> >>> I did, with todays sources: >>> >>> malpertuus: /cygdrive/e/pp/projects/lazarus/examples >./edittest >>> [FORMS.PP] ExceptionOccurred >>> Sender=EACCESSVIOLATION >>> Exception=Access violation >>> TApplication.HandleException Access violation >>> TApplication.HandleException Handling "Access violation" ... >>> [FORMS.PP] ExceptionOccurred >>> >>> Not very informative :-/ >> >> Follow-up: >> >> Executing progressbar (or any other) example, >> I get zillions of these messages: >> >> Exception=Unknown Run-Time error : 217 >> TApplication.HandleException: there was another exception during >> showing the first exception [FORMS.PP] ExceptionOccurred >> Sender=EXCEPTION >> Exception=Unknown Run-Time error : 217 >> >> So something is definitely wrong in the windows interface:/ > > Strange, I do not recieve such messages. Only when trying to execute > lazarus, but the progressbar example works fine. > > Micha. Same here, but the progressbar example has a new bug: When you click on toggle smooth, all buttons disappear and only every second a blue block is shown. I might have to do something with the changes to the code of wm_erasebackground recently.

I found it! The BeginPaint function is not implemented in lcl/include/winapi.inc. Can we introduce a method for it in the interface?

Regards,

Micha.

Reply by email

Micha Nelissen
to Michael Van Canneyt: Follow-up: Executing progressbar (or any other) example, I get zillions of these messages:
Michael Van Canneyt wrote 36 lines
On Tue, 1 Jul 2003, Michael Van Canneyt wrote: > > >>> Ultimate reason: the win32 interface seems to crash when a >>> shortcut is set >>> for a particular menuitem. It occurs when running the lazarus ide. >> >> I'm sure you will find the bug. >> >> Apropos IDE: Did you try the TSynEdit under win32? > > I did, with todays sources: > > malpertuus: /cygdrive/e/pp/projects/lazarus/examples >./edittest > [FORMS.PP] ExceptionOccurred > Sender=EACCESSVIOLATION > Exception=Access violation > TApplication.HandleException Access violation > TApplication.HandleException Handling "Access violation" ... > [FORMS.PP] ExceptionOccurred > > Not very informative :-/ Follow-up: Executing progressbar (or any other) example, I get zillions of these messages: Exception=Unknown Run-Time error : 217 TApplication.HandleException: there was another exception during showing the first exception [FORMS.PP] ExceptionOccurred Sender=EXCEPTION Exception=Unknown Run-Time error : 217 So something is definitely wrong in the windows interface:/

Strange, I do not recieve such messages. Only when trying to execute lazarus, but the progressbar example works fine.

Micha.

Reply by email

Micha Nelissen
to Vincent Snijders: ide. Same here, but the progressbar example has a new bug: When you click on toggle…
Vincent Snijders wrote 48 lines
> Van: Micha Nelissen > Verzonden: dinsdag 1 juli 2003 13:43 > Michael Van Canneyt wrote: >> On Tue, 1 Jul 2003, Michael Van Canneyt wrote: >> >>> >>> >>>>> Ultimate reason: the win32 interface seems to crash when a >>>>> shortcut is set >>>>> for a particular menuitem. It occurs when running the lazarus >>>>> ide. >>>> >>>> I'm sure you will find the bug. >>>> >>>> Apropos IDE: Did you try the TSynEdit under win32? >>> >>> I did, with todays sources: >>> >>> malpertuus: /cygdrive/e/pp/projects/lazarus/examples >./edittest >>> [FORMS.PP] ExceptionOccurred >>> Sender=EACCESSVIOLATION >>> Exception=Access violation >>> TApplication.HandleException Access violation >>> TApplication.HandleException Handling "Access violation" ... >>> [FORMS.PP] ExceptionOccurred >>> >>> Not very informative :-/ >> >> Follow-up: >> >> Executing progressbar (or any other) example, >> I get zillions of these messages: >> >> Exception=Unknown Run-Time error : 217 >> TApplication.HandleException: there was another exception during >> showing the first exception [FORMS.PP] ExceptionOccurred >> Sender=EXCEPTION >> Exception=Unknown Run-Time error : 217 >> >> So something is definitely wrong in the windows interface:/ > > Strange, I do not recieve such messages. Only when trying to execute > lazarus, but the progressbar example works fine. > > Micha. Same here, but the progressbar example has a new bug: When you click on toggle smooth, all buttons disappear

Why do all buttons disappear, I can reason that the smooth button disappears because erasebackground redraws over it or something, but why do *all* of them disappear? IOW: If only 1 item needs to be redrawn, why are all?

and only every second a blue block is shown.

It's meant to be like this. By default, smooth is 'on', toggling smooth disables smooth, and thus 'blocky'.

I might have to do something with the changes to the code of wm_erasebackground recently.

Indeed.

Regards,

Micha.

Reply by email

Vincent Snijders
Show quoted text 10 lines
Van: Micha Nelissen Verzonden: dinsdag 1 juli 2003 13:43 Michael Van Canneyt wrote: > On Tue, 1 Jul 2003, Michael Van Canneyt wrote: > >> >> >>>> Ultimate reason: the win32 interface seems to crash when a >>>> shortcut is set >>>> for a particular menuitem. It occurs when running the lazarus

ide.

Show quoted text 34 lines
>>> >>> I'm sure you will find the bug. >>> >>> Apropos IDE: Did you try the TSynEdit under win32? >> >> I did, with todays sources: >> >> malpertuus: /cygdrive/e/pp/projects/lazarus/examples >./edittest >> [FORMS.PP] ExceptionOccurred >> Sender=EACCESSVIOLATION >> Exception=Access violation >> TApplication.HandleException Access violation >> TApplication.HandleException Handling "Access violation" ... >> [FORMS.PP] ExceptionOccurred >> >> Not very informative :-/ > > Follow-up: > > Executing progressbar (or any other) example, > I get zillions of these messages: > > Exception=Unknown Run-Time error : 217 > TApplication.HandleException: there was another exception during > showing the first exception [FORMS.PP] ExceptionOccurred > Sender=EXCEPTION > Exception=Unknown Run-Time error : 217 > > So something is definitely wrong in the windows interface:/ Strange, I do not recieve such messages. Only when trying to execute lazarus, but the progressbar example works fine. Micha.

Same here, but the progressbar example has a new bug: When you click on toggle smooth, all buttons disappear and only every second a blue block is shown. I might have to do something with the changes to the code of wm_erasebackground recently.

Vincent

Reply by email

Mattias Gaertner
to Vincent Snijders: Forwarded to the list. -----Oorspronkelijk bericht----- Van: Micha Nelissen Verzonden:…
Show quoted text 8 lines
> Same here, but the progressbar example has a new bug: When you click > on toggle smooth, all buttons disappear and only every second a blue > block is shown. I might have to do something with the changes to the > code of wm_erasebackground recently. I found it! The BeginPaint function is not implemented in lcl/include/winapi.inc. Can we introduce a method for it in the interface?

Added.

Mattias

Reply by email

Florian Klaempfl
to Vincent Snijders: Forwarded to the list. -----Oorspronkelijk bericht----- Van: Micha Nelissen Verzonden:…
Micha Nelissen wrote 22 lines
Mattias Gaertner wrote: >On Tue, 1 Jul 2003 15:28:55 +0200 >"Vincent Snijders" wrote: > > >>>Same here, but the progressbar example has a new bug: When you click >>>on toggle smooth, all buttons disappear and only every second a blue >>>block is shown. I might have to do something with the changes to the >>>code of wm_erasebackground recently. >> >>I found it! The BeginPaint function is not implemented in >>lcl/include/winapi.inc. Can we introduce a method for it in the >>interface? > >Added. Well, completing the interface implementation does make it all work. I have attached a patch for that. But: it has a gigantic memory leak. If I take the progressbar example and let it fire every 50ms, memory is depleted in 10 seconds. Not good.

Did you try -gh?

Reply by email