Results 1 to 8 of 8

Thread: Convert VB6 Shangle

  1. #1

    Thread Starter
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796

    Convert VB6 Shangle

    Here's a bit of simple VB6 code that puts a shangle (resizing handle) on a form. The actual code I use has been re-written as a user control, but this code is the minimum simple representation of the concept.

    What's the best way to do the same thing in .Net? Should I be using API calls at all, or can I do the same thing directly with net framework?

    I do realise that I can still use the VB6 user control under .net, but that would defeat the purpose of the exercise, which is to learn .net.

    This is the heart of the (VB6) code:

    VB Code:
    1. Option Explicit
    2.  
    3. Declare Function ReleaseCapture Lib "user32" () As Long
    4. Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    5.  
    6. Const WM_NCLBUTTONDOWN = &HA1
    7. Const HTBOTTOMRIGHT = 17
    8. Sub DriveShangle(f As Form)
    9.  
    10.   'PURPOSE: Negate VB's call to SetCapture, and tell Windows
    11.   '         that the user is trying to resize the form.
    12.    
    13.   'Cancel the capture on the label
    14.   ReleaseCapture
    15.  
    16.  'Set the capture on the form's bottom-right grab-handle instead
    17.   SendMessage f.hwnd, WM_NCLBUTTONDOWN, HTBOTTOMRIGHT, ByVal 0&
    18.  
    19. End Sub

    A complete running example (VB6) is attached.
    Attached Files Attached Files
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    You don't have to convert it to .Net since a Windows Form in .Net has a SizeGripStyle property that you can set to True.

  3. #3

    Thread Starter
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    I have a feeling of deja vu...
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  4. #4
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Originally posted by BrianHawley
    I have a feeling of deja vu...
    You said that before
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  5. #5

    Thread Starter
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    Hi Stuart.

    Joacim posted the same reply in both forums.
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  6. #6
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Sorry Brian, it was a lame attempt at a deja vu joke ...
    Go about your business nothing to see here
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  7. #7

    Thread Starter
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    Well I still have a feeling of deja vu.
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  8. #8

    Thread Starter
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    Well I still have a feeling of deja vu
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width