Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form - resize rubber band
Message
From
22/09/2004 07:59:34
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00944495
Message ID:
00944924
Views:
16
Frank,

>Herman,
>
>>Sorry Frank, my bad :-(
>>Here is the example to draw the rectangle on the border: ...
>
>Yes, great. It took me a while to understand that drawing the border will draw it, drawing it again with the same coordinates will remove it, right?
>

Right, that's what SetROP2 is for.


>I needed to mimic Your function "buff2Num" but I have a function "String2Long" that does the job. Took some modifications but works.
>

Arrgghh.. I really forgot that. I'm sorry, it's because I cut and paste (here and there) from my program. Good to hear you can make it :-)

Anyway here is the function:
Function Word2Num( tc_Buffer, tl_MSB )
Local ln_Word

   If tl_MSB
      ln_Word = asc(substr( tc_Buffer, 2, 1 )) + asc(substr( tc_Buffer, 1, 1 )) * 256
   else
      ln_Word = asc(substr( tc_Buffer, 1, 1 )) + asc(substr( tc_Buffer, 2, 1 )) * 256
   endif

   Return ln_Word
EndFunc


Function DWord2Num( tc_Buffer, tl_MSB )
Local ln_Result

   If tl_MSB
      ln_Result = asc(substr( tc_Buffer, 4, 1 )) + ;
         asc(substr( tc_Buffer, 3, 1 )) * 256 + ;
         asc(substr( tc_Buffer, 2, 1 )) * 65536 + ;
         asc(substr( tc_Buffer, 1, 1 )) * 16777216
   else
      ln_Result = asc(substr( tc_Buffer, 1, 1 )) + ;
         asc(substr( tc_Buffer, 2, 1 )) * 256 + ;
         asc(substr( tc_Buffer, 3, 1 )) * 65536 + ;
         asc(substr( tc_Buffer, 4, 1 )) * 16777216
   endif

   Return ln_Result
EndFunc


Function Buff2Num( tc_Buffer, tn_Pos, tl_DWord, tl_MSB )
Local ln_Result

   If tl_DWord
      ln_Result = DWord2Num( substr( tc_Buffer, tn_Pos, 4 ), tl_MSB )
   else
      ln_Result = Word2Num( substr( tc_Buffer, tn_Pos, 2 ), tl_MSB )
   endif

   Return ln_Result
EndFunc
>I have now three methods GetWindowRectangle(), DrawRubber() and ClearRubber() where the latter simply calls DrawRubber() with the old coordinates.
>
>Upon MouseDown(), I GetWindowRectangle() and calculate the MouseOffsets. Then Draw the Rubberband.
>On MouseMove(), I call a ClearRubber() and a DrawRubber() with the corrected Mouse-Offsets
>Finally on MouseUp() I call a ClearRubber() and do the Resizing of the form.
>
>Works like a charm
>

Glad it works :-)
BTW, GetWindowRect function already returned the correct rectangle. So it doesn't have to convert to screen (no need ClientToScreen).


>Two questions:
>- Is it correct that I need to redraw the rectangle with every mouseMove or could I also resize it?

Yes, you have to redraw it every MouseMove.


>- Could I draw the Rubber the way windows does it with the thick black/white rastered line?
>

Yes you can, a little more work to do.

- Create the bitmap based on custom pattern (CreateBitmap).
WORD   rgbPatGray[8] = { 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA };
- Create the pattern brush from the bitmap (CreatePatternBrush)
- Select the pattern brush into DC
- Because this technique using a pattern brush, you can't use rectangle. It will fills the whole rectangle area. So you have to draw each side of the border ( 4 times ) using PatBlt with PATINVERT (you can specfy the border width to draw )
- Don't forget to delete the GDI object that you created (DeleteObject)

Actually, for the first workaround, you can also make it thicker. Just create the pen (CreatePen) then select the Handle Pen into DC.

>Thanks again

You're welcome
Herman
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform