[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:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim msg As New Message()
Dim hWnd As New IntPtr(1501598)
msg = Message.Create(hWnd, msg.Msg, msg.WParam, msg.LParam)
End Sub
Private Function LRESULT_CALLBACK_WndProc(ByVal hWnd As IntPtr, ByVal message As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
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
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
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.
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
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
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
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?
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
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
Re: [2005] Convert this code into visual basic (C++ I think)
ElseIf :P I didn't notice that, and MsgBox > MessageBox :)
Re: [2005] Convert this code into visual basic (C++ I think)
msgbox is legacy
messagebox.show is a far superior method
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
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.
Re: [2005] Convert this code into visual basic (C++ I think)
Quote:
Originally Posted by Fromethius
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:
if val("msgbox") > val("messagebox.show") then
messagebox.show("icyculyr is right")
else
messagebox.show("icyculyr is wrong")
end if
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 :)
Re: [2005] Convert this code into visual basic (C++ I think)
Quote:
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)
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:
If Message = WM_ACTIVATE Then
'Extend the frame into the client area.
Dim margins As MARGINS
margins.cxLeftWidth = LEFTEXTENDWIDTH
margins.cxRightWidth = RIGHTEXTENDWIDTH
margins.cyBottomHeight = BOTTOMEXTENDWIDTH
margins.cyTopHeight = TOPEXTENDWIDTH
hr = DwmExtendFrameIntoClientArea(hWnd, margins)
If (Not SUCCEEDED(hr)) Then
'Handle error.
End If
fCallDWP = True
lRet = 0
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:
Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarInset As MARGINS) As Integer
End Function
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.
Re: [2005] Convert this code into visual basic (C++ I think)
Quote:
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