Resizable empty window

4 posts / 0 new
Last post
JosDuchIt
JosDuchIt's picture
Offline
Last seen: 8 years 6 days ago
Joined: 2012-01-08 20:57
Resizable empty window

For testing purposes i do need a window that should be resizable and when resized should print out the new dimensions, say on clicking the mouse.

I used

  1. tags[c].ti_Tag = WA_SizeGadget;
  2. tags[c].ti_Data = TRUE; ++c;
  3. tags[c].ti_Tag = WA_CloseGadget;
  4. tags[c].ti_Data = TRUE; ++c;
  5. tags[c].ti_Tag = WA_IDCMP;
  6. tags[c].ti_Data = IDCMP_CLOSEWINDOW | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE ; ++c

and the ReplyMsg code looks like

  1. BOOL handleIDCMP(struct Window *win, BOOL done)
  2. {
  3. struct IntuiMessage *message;
  4. USHORT code;
  5. SHORT mousex, mousey;
  6. ULONG class;
  7.  
  8.  
  9. while (NULL != (message = (struct IntuiMessage *)GetMsg(win->UserPort)))
  10. {
  11.  
  12. class = message->Class;
  13. code = message->Code;
  14. mousex = message->MouseX;
  15. mousey = message->MouseY;
  16.  
  17.  
  18. ReplyMsg((struct Message *)message);
  19.  
  20. /* The class contains the IDCMP type of the message. */
  21. switch (class)
  22. {
  23. case IDCMP_CLOSEWINDOW:
  24. done = TRUE;
  25. break;
  26.  
  27. case IDCMP_NEWSIZE:
  28. break;
  29. case IDCMP_MOUSEBUTTONS:
  30. switch (code)
  31. {
  32. case SELECTUP:
  33. getdimensions();
  34. break;
  35.  
  36. default:
  37. printf("UNKNOWN CODE\n");
  38. break;
  39. }
  40. break;
  41. default:
  42. printf("Unknown IDCMP message\n");
  43. break;
  44. }
  45. }
  46. return(done);
  47. }

The window opens, has a size gadget indeed, but i can't resize it ???
Using the mouse i do get the wanted output. I can close it.

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
You need to set WA_MinWidth,

You need to set WA_MinWidth, WA_MinHeight, WA_MaxWidth and WA_MaxHeight, too. They all default to WA_Width resp. WA_Height leaving you with a non-movable size gadget.

And you don't get IDCMP_MOUSEBUTTON messges when you click on a GUI object. You should put getdimensions() into the IDCMP_NEWSIZE section. IDCMP_MOUSEBUTTON messages are only received it no other GUI element takes them.

JosDuchIt
JosDuchIt's picture
Offline
Last seen: 8 years 6 days ago
Joined: 2012-01-08 20:57
You need to set WA_MinWidth,

You need to set WA_MinWidth, WA_MinHeight, WA_MaxWidth and WA_MaxHeight, too. They all default to WA_Width resp. WA_Height leaving you with a non-movable size gadget.

Thanks a lot Thomas.
And you don't get IDCMP_MOUSEBUTTON messges when you click on a GUI object. You should put getdimensions() into the IDCMP_NEWSIZE section. IDCMP_MOUSEBUTTON messages are only received it no other GUI element takes them.

As a matter of fact i don't want to have the size info during the resize but after.

Gui4Cli allows you with Ctl_W to 'note' the size of a resized gui, and use this afterwards as minimum or maximum size. The results are not the same as the on you get with just opening a window at these sizes. I just want to investigate where this discrepancy has its origun from.

hypex
hypex's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2011-09-09 16:20
Interesting use of tags

Interesting use of tags there. Don't forget to put a TAG_END on the end of your taglist. :-)

Log in or register to post comments