Page 1 of 1

Large numbers of DCPUSHButtons

Posted: Wed Mar 20, 2013 1:00 am
by gradosic
Hi everyone,

We have one issue with creating large numbers of pushbuttons because they are working very slow.

To explain whole thing: It’s in POS application for restaurant where we have main screen with articles on screen, browse, etc., and one of features is “table preview” where waiters can see schematic preview of tables. Of course they call this “tables preview” when they need it, and if there is 20-30 tables (pushbuttons) on this preview it takes 1-2 seconds for application to create this window and show tables. Usually when you say 1-2 seconds, it’s doesen't seems to long, but believe me when is rush time it’s disaster! Is there any way that I can create this screen with tables (lots of pushbuttons) and keep it in memory, and just to call that screen when I need it (so I don’t need to create every time). Another thread or something?

To explain better I attach preview of main screen (main.PNG) and screen of tables (tables preview)... also I put part of code that draw this pushbuttons (table) on screen.

Re: Large numbers of DCPUSHButtons

Posted: Wed Mar 20, 2013 2:17 am
by c-tec
Hello,
have the same problem, I think gradient and such things are slowing down. They are also flashing very slow on a refresh oder some events
regards
Rudolf

Re: Large numbers of DCPUSHButtons

Posted: Wed Mar 20, 2013 3:12 am
by gradosic
Hi,

Gradient? You mean pictures and similar? That's no issue, becaouse i try (for test) instead pushbuttons to put small static objects with text, and also is slow... It simply need time to draw window, and only way to avoid that is to keep window "somewhere down" and show it when needed... but I don't know how..

Re: Large numbers of DCPUSHButtons

Posted: Wed Mar 20, 2013 5:45 am
by skiman
Hi,

Put the buttons on a static and hide the static. As soon as you need it, show the static.

Re: Large numbers of DCPUSHButtons

Posted: Wed Mar 20, 2013 5:54 am
by gradosic
Hi Chris,

thanks for reply but if I do that like this, I'm not able to keep focus on that static... in that case user can also click main screen... ? any other sugestion?

Re: Large numbers of DCPUSHButtons

Posted: Wed Mar 20, 2013 7:26 am
by rdonnay
Show me the code that you use to create the buttons.

Re: Large numbers of DCPUSHButtons

Posted: Wed Mar 20, 2013 7:39 am
by gradosic
Roger,

code in attach

Re: Large numbers of DCPUSHButtons

Posted: Wed Mar 20, 2013 8:45 am
by rdonnay
I looked at your code and I think that much of the slowness is due to the fact that you are using DCPUSHBUTTON STATIC buttons. If I could get rid of this code in eXpress++ I would do so but there is such a thing as a "legacy".

I developed the DCPUSHBUTTONXP style buttons soon after Xbase++ started supporting Ownerdrawing for the XbpPushButton() class. This is a much better way to create complex and visually appealling buttons because there is only one object created for each button.

Run the \exp19\samples\buttonxp\buttonxp.prg sample program.
You will see that it will create many buttons on the screen very quickly.
Also, I recommend creating only 1 bitmap for all your buttons instead of separate bitmaps.

Example:

oBitmap := DC_GetBitMap('Table.Jpg')

@ 1,1 DCPUSHBUTTONXP CAPTION '1' BITMAP oBitmap
@ 2,1 DCPUSHBUTTONXP CAPTION '2' BITMAP oBitmap

This is a simplified explanation. In your case you will probably want to use a CAPTIONARRAY clause.
Look at this in the sample program.

Re: Large numbers of DCPUSHButtons

Posted: Wed Mar 20, 2013 1:37 pm
by Auge_Ohr
gradosic wrote:We have one issue with creating large numbers of pushbuttons because they are working very slow.
as i "see" you use Tabpage too and i guess there are more Pushbuttons ...
as Chris say : hide all when create and show when need but you just need to show what you can see

Question : are you create Pushbutton for other Tabpage in same Thread ?

once i did had create a virtual Keyboard and start with 102 Pushbutton ... but that was "slow"
next Version was just 1 Static but "inside" i paint a X / Y Grid which act as "Button" ( LbDown)

p.s. Xbase++ use GDI32 which is 2D. if you compare Grafic-Card 2D Benchmark you will "see"
that "power" GFK like NVidea 680 are "less" than Intel "build-in" HD4000 GFK Solution.

Re: Large numbers of DCPUSHButtons

Posted: Wed Mar 20, 2013 1:56 pm
by gradosic
Auge i't possible to create static object, but when I put buttons in static and HIDE static, buttons stay visible even they are parent to static... Why hide function don't work with parent obect inside static?