Results 1 to 19 of 19

Thread: [2005] Convert this code into visual basic (C++ I think)

  1. #1

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    [2005] Convert this code into visual basic (C++ I think)

    Code:
     Copy Code
    // Handle window activation.
    if (message == WM_ACTIVATE)
    {
        // Extend the frame into the client area.
        MARGINS margins;
    
        margins.cxLeftWidth = LEFTEXTENDWIDTH;      //8
        margins.cxRightWidth = RIGHTEXTENDWIDTH;    //8
        margins.cyBottomHeight = BOTTOMEXTENDWIDTH; //20
        margins.cyTopHeight = TOPEXTENDWIDTH;       //27
    
        hr = DwmExtendFrameIntoClientArea(hWnd, &margins);
    
        if (!SUCCEEDED(hr))
        {
            // Handle error.
        }
    
        fCallDWP = true;
        lRet = 0;
    }
    I've tried something like this:

    vb.net Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim msg As New Message()
    3.         Dim hWnd As New IntPtr(1501598)
    4.         msg = Message.Create(hWnd, msg.Msg, msg.WParam, msg.LParam)
    5.  
    6.     End Sub
    7.  
    8.     Private Function LRESULT_CALLBACK_WndProc(ByVal hWnd As IntPtr, ByVal message As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
    9.  
    10.  
    11.     End Function

    But it does nothing, I don't know what im supposed to do lol..

    I am trying to change the colour of my window frame & buttons etc...

    Thanks

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [2005] Convert this code into visual basic (C++ I think)

    looks like c# to me.
    also seems to be unrelated to frame or button colours

  3. #3
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: [2005] Convert this code into visual basic (C++ I think)

    what makes you think it's c#? There's nothing there in that code that gives that away.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  4. #4

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2005] Convert this code into visual basic (C++ I think)

    It's a part of code which the thing wants me to put into my code, I got it from MSDN, the language was Visual Basic...

    It's the type of code you put in a console application I think...
    (which is C++ or C)

    The link for the file in VS - Search is 'http://msdn2.microsoft.com/en-us/library/bb688195.aspx'

    That code is for modifying the border width etc..

    Thanks

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [2005] Convert this code into visual basic (C++ I think)

    it was a guess. i can barely read c#. dunno about c++

    have you tried the online converters?

    http://codeconverter.sharpdevelop.net/

    http://www.kamalpatel.net/ConvertCSharp2VB.aspx

  6. #6

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2005] Convert this code into visual basic (C++ I think)

    I thought code converters were bad?
    and I would like to understand a bit about what I am doing, so that when I go and learn C++ I will have some idea of how this works...

    Thanks

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [2005] Convert this code into visual basic (C++ I think)

    wheres the learning advantage between converting code using a code converter + having someone in the forum convert it for you?

  8. #8

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2005] Convert this code into visual basic (C++ I think)

    Because I will ask questions about the code converted by the person in VB, where as the code converter isn't very talkative...

    Cheers

  9. #9
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [2005] Convert this code into visual basic (C++ I think)

    2 observations about your signature

    'Elseif' without condition is invalid

    messagebox.show is the preferred vb.net method

  10. #10

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2005] Convert this code into visual basic (C++ I think)

    ElseIf :P I didn't notice that, and MsgBox > MessageBox

  11. #11
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [2005] Convert this code into visual basic (C++ I think)

    msgbox is legacy

    messagebox.show is a far superior method

  12. #12
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Re: [2005] Convert this code into visual basic (C++ I think)

    We have a thread regarding legacy functions if anyone is up for a good read:

    http://vbforums.com/showthread.php?t=500510

  13. #13
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: [2005] Convert this code into visual basic (C++ I think)

    if you think a code converter isn't very talkative, you haven't tried the one that converts vb6 to vb.net. A notation on nearly every line.
    Last edited by Lord Orwell; Dec 15th, 2007 at 07:59 PM.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  14. #14
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [2005] Convert this code into visual basic (C++ I think)

    Quote Originally Posted by Fromethius
    We have a thread regarding legacy functions if anyone is up for a good read:

    http://vbforums.com/showthread.php?t=500510
    i missed it. the microsoft chat that is. but my concerns were covered anyway.

    heres a test that proves msgbox isnot greater than messagebox.show

    vb.net Code:
    1. if val("msgbox") > val("messagebox.show") then
    2.    messagebox.show("icyculyr is right")
    3. else
    4.    messagebox.show("icyculyr is wrong")
    5. end if

  15. #15

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2005] Convert this code into visual basic (C++ I think)

    the time it takes for MsgBox to be typed is one third of the time of MessageBox.Show()...

    I see MsgBox as better

  16. #16

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2005] Convert this code into visual basic (C++ I think)

    if you think a code converter isn't very talkative, you haven't tried the one that converts vb6 to vb.net. A notation on nearly line.
    My code is not vb6, it is C++, and it needs to become vb.net, which I am not sure is even possible O_O, nor would I understand how to implement it...

    I am TypeOf(Noob)

  17. #17
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Convert this code into visual basic (C++ I think)

    With a code snippet MessageBox.Show is faster to enter than MsgBox. Given that MsgBox calls MessageBox.Show, it is also faster to execute, therefore superior.

    A competent VB coder should be able to get most of that by eye:
    vb.net Code:
    1. If Message = WM_ACTIVATE Then
    2.     'Extend the frame into the client area.
    3.     Dim margins As MARGINS
    4.  
    5.     margins.cxLeftWidth = LEFTEXTENDWIDTH
    6.     margins.cxRightWidth = RIGHTEXTENDWIDTH
    7.     margins.cyBottomHeight = BOTTOMEXTENDWIDTH
    8.     margins.cyTopHeight = TOPEXTENDWIDTH
    9.  
    10.     hr = DwmExtendFrameIntoClientArea(hWnd, margins)
    11.  
    12.     If (Not SUCCEEDED(hr)) Then
    13.         'Handle error.
    14.     End If
    15.  
    16.     fCallDWP = True
    17.     lRet = 0
    18. End If
    Not really very different, is it? There are obviously a few type, function and constant declarations to make there.

    Note that the DwmExtendFrameIntoClientArea function expects a pointer as the second parameter. That's why this:
    Code:
    hr = DwmExtendFrameIntoClientArea(hWnd, &margins);
    is specifying that the address of the value, rather than the value itself, is passed. In VB you would simply declare that function parameter ByRef:
    vb.net Code:
    1. Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarInset As MARGINS) As Integer
    2. End Function
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  18. #18
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: [2005] Convert this code into visual basic (C++ I think)

    as for code converting in general, it's usually easier to start over with new code.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  19. #19

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2005] Convert this code into visual basic (C++ I think)

    A competent VB coder should be able to get most of that by eye:
    I can convert the code, but my problem was the functions? I did not know they were functions, I thought they were something else lol...

    Cheers

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