Sunday, January 23, 2005

FrmReturnToForm and the handled flag-trouble straight ahead

After having solved my variable-related problems, new ones-this time involving a popup form-have arisen. The world of PODS seems like a saga from homer-solve one thing and face the next... .
A modal form was popped up using FrmPopupForm. To all new hands here: FrmPopupForm allows you to install a new event handler for the popup. Unlike FrmDoDialog you actually can control how the form behaves on the screen.
When the form must be removed, FrmReturnToForm is used. Usually, the ID of the form below is used, but some smarter developers simply pass 0 to refer to the form below.
However, sometimes this simple strategy fails with the most ridiculous errors. Look at the codepiece below for a potential candidate:

case ctlCloseForm:
FrmReturnToForm(0);
break;

Compile, run on debug ROM-Nice fatal alert about an invalid pointer. Can you bust the bug? Ridiculous, but true-the handled flag is not set to true. Simply changing the code to set the flag solves the problem-see below:

case ctlCloseForm:
FrmReturnToForm(0);
handled=true;
break;

This looks amusing-invalid memory because of not setting the handled field. So-we have a new rule for Ben Combee's rule list:
Set thy handled field to true or false-or find thy head handled by the gallows!
Now-the rule is proven-but why? After a short think a solution can be found-it should the OS event handlers causing the bug. FrmReturnToForm removes the form from memory immediately-but since the handled flag is not set, an event concerning this form still gets to the OS "event dump". There, the debug ROM seems to verify the event's data-and boom. This is of course only an assumption-anybody with a better explanation is urged to use the (anonymous) comment facility.

7 Comments:

Blogger Ben Combee said...

You actually can do a lot with FrmDoDialog:

1) You can draw the form and set controls ahead of calling FrmDoDialog to customize the data in the form.
2) You can set a custom event handler using FrmSetEventHandler, and that will be called by the FrmDoDialog event loop before it processes events.

The main reason to use FrmPopupForm is if you're using an alternative event source or a program-wide event filter. Otherwise, FrmDoDialog really works pretty well.

9:45 PM  
Blogger Tam Hanna said...

Hi ben,
a perfect comment as always!
In the applicastion where the bug occurred, I needed the event handling for the actualization of a preview. But since development has been halted-forget it...
Best regards
Tam Hanna

7:10 PM  
Blogger kobeli said...

Cheap Christian Louboutin Shoes
cheap air jordan shoes
Ralph Lauren Polo Shirts
Nfl jerseys

Christian Louboutin Sandals
nike air jordan shoes
Polo Shirts
Nhl jerseys
ugg winter boots
ugg winter boots
Buffalo Bills jerseys
ugg boots on sale
Bailey Button Uggs
Christian Louboutin Sandals
Bailey Button Uggs
Cardy Ugg Boots
Cheap Christian Louboutin
Cardy Ugg BootsClassic Crochet Uggs
New Style Christian Louboutin
Classic Crochet Uggs
Classic Short Ugg Boots
Christian Louboutin Boots
Classic Crochet Uggs
Classic Short Ugg Paisley Boots
Manolo Blahnik

8:20 AM  
Blogger oakleyses said...

cheap oakley sunglasses, louis vuitton outlet, uggs on sale, michael kors outlet online, prada outlet, michael kors outlet online, ugg boots, oakley sunglasses, longchamp outlet, oakley sunglasses, oakley sunglasses wholesale, jordan shoes, michael kors outlet online, christian louboutin shoes, michael kors outlet, replica watches, gucci handbags, louis vuitton outlet, uggs outlet, polo outlet, nike free, chanel handbags, michael kors outlet online, christian louboutin outlet, oakley sunglasses, ugg boots, uggs outlet, kate spade outlet, nike air max, nike outlet, longchamp outlet, ray ban sunglasses, louis vuitton outlet, ray ban sunglasses, christian louboutin, longchamp outlet, michael kors outlet, louis vuitton, burberry handbags, nike air max, tiffany jewelry, burberry outlet, polo ralph lauren outlet online, tiffany and co, ray ban sunglasses

2:51 AM  
Blogger oakleyses said...

polo lacoste, burberry pas cher, true religion outlet, hollister uk, ray ban pas cher, replica handbags, ralph lauren uk, nike free uk, michael kors, true religion outlet, north face uk, nike roshe, sac longchamp pas cher, timberland pas cher, longchamp pas cher, coach outlet, mulberry uk, nike blazer pas cher, kate spade, nike air max, true religion jeans, true religion outlet, lululemon canada, nike free run, ray ban uk, nike roshe run uk, converse pas cher, guess pas cher, hollister pas cher, nike tn, michael kors pas cher, oakley pas cher, nike air max uk, nike air force, sac vanessa bruno, jordan pas cher, new balance, north face, coach purses, vans pas cher, nike air max uk, sac hermes, hogan outlet, louboutin pas cher, air max, michael kors, michael kors outlet, abercrombie and fitch uk, coach outlet store online, polo ralph lauren

2:53 AM  
Blogger oakleyses said...

iphone cases, ipad cases, iphone 6 plus cases, bottega veneta, chi flat iron, louboutin, iphone 6s cases, insanity workout, nike roshe run, babyliss, hollister, p90x workout, vans outlet, s6 case, lululemon, mac cosmetics, jimmy choo outlet, hollister clothing, nfl jerseys, north face outlet, nike huaraches, oakley, soccer jerseys, nike trainers uk, instyler, baseball bats, mcm handbags, mont blanc pens, herve leger, wedding dresses, ferragamo shoes, north face outlet, giuseppe zanotti outlet, timberland boots, ghd hair, ralph lauren, soccer shoes, iphone 5s cases, abercrombie and fitch, hermes belt, iphone 6s plus cases, valentino shoes, celine handbags, beats by dre, longchamp uk, new balance shoes, nike air max, reebok outlet, iphone 6 cases

2:54 AM  
Blogger oakleyses said...

wedding dresses, moncler outlet, pandora jewelry, toms shoes, converse, louis vuitton, ugg uk, ray ban, moncler, links of london, nike air max, marc jacobs, karen millen uk, moncler outlet, canada goose uk, canada goose outlet, ugg pas cher, juicy couture outlet, pandora jewelry, lancel, barbour, canada goose, hollister, swarovski, louis vuitton, hollister, doudoune moncler, canada goose outlet, louis vuitton, swarovski crystal, converse outlet, montre pas cher, moncler uk, coach outlet, thomas sabo, canada goose, canada goose, ugg,ugg australia,ugg italia, louis vuitton, vans, moncler, ugg, louis vuitton, barbour uk, moncler, pandora uk, replica watches, canada goose outlet, gucci, doke gabbana, pandora charms, supra shoes, moncler

2:55 AM  

Post a Comment

<< Home