|
-
Dec 14th, 2007, 09:45 PM
#1
Thread Starter
Frenzied Member
[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
-
Dec 14th, 2007, 10:46 PM
#2
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
-
Dec 14th, 2007, 11:17 PM
#3
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.
-
Dec 14th, 2007, 11:42 PM
#4
Thread Starter
Frenzied Member
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
-
Dec 15th, 2007, 12:53 AM
#5
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
-
Dec 15th, 2007, 04:39 PM
#6
Thread Starter
Frenzied Member
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
-
Dec 15th, 2007, 06:03 PM
#7
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?
-
Dec 15th, 2007, 06:11 PM
#8
Thread Starter
Frenzied Member
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
-
Dec 15th, 2007, 06:22 PM
#9
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
-
Dec 15th, 2007, 06:25 PM
#10
Thread Starter
Frenzied Member
Re: [2005] Convert this code into visual basic (C++ I think)
ElseIf :P I didn't notice that, and MsgBox > MessageBox
-
Dec 15th, 2007, 06:28 PM
#11
Re: [2005] Convert this code into visual basic (C++ I think)
msgbox is legacy
messagebox.show is a far superior method
-
Dec 15th, 2007, 07:21 PM
#12
Frenzied Member
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
-
Dec 15th, 2007, 07:50 PM
#13
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.
-
Dec 15th, 2007, 07:51 PM
#14
Re: [2005] Convert this code into visual basic (C++ I think)
 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
-
Dec 15th, 2007, 07:55 PM
#15
Thread Starter
Frenzied Member
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
-
Dec 15th, 2007, 07:56 PM
#16
Thread Starter
Frenzied Member
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)
-
Dec 16th, 2007, 07:09 AM
#17
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
-
Dec 16th, 2007, 08:54 AM
#18
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.
-
Dec 16th, 2007, 03:35 PM
#19
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|