|
As far as I know, you can't. Because a Message Box is created by Windows (Msg.cpl I think), and the font is preset.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
You can create your own messagebox and use the new messagebox instead of using the native .NET messagebox. I think you can do a quick search here, at the codeproject, and you should be able to find exactly what you need.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
|
|
Hi,
first of all sorry for my bad english.
I have a problem, I have a String like this "System.Data.DataTable" and I wont to convert this String now in a Type of this String.
That works for example with the string "System.Object", but with the String above I got Nothing.
Type.GetType("System.Data.DataTable")
For sure I can save the long version with this:
TheClass.GetType().AssemblyQualifiedName
Than also the creating is no problem, but if I understand it right than is this long version only for one PC and this is for sure shity.
Can someone help me?
mfg
|
|
|
|
|
Curse4Life wrote: For sure I can save the long version with this:
TheClass.GetType().AssemblyQualifiedName
Than also the creating is no problem, but if I understand it right than is this long version only for one PC and this is for sure *****
Please don't use profanity in the programming forums. If you must swear then please go to the Soapbox.
The long version is not tied to one PC. It will work on any PC where the appropriate assembly is installed.
|
|
|
|
|
First of all, thanks for your answer, this realy help me out.
But now I have a new problem.
Now I have create an instans of this type but now I have to fill the properties, problem is, I have all Properties in Strings, but I also have to fill integer an boolean properties of this new instans.
So I can set an value
TempObject.GetType().GetProperty(MyProperty.Name).SetValue(TempObject, MyProperty.Value, Nothing)
but how I said, a Type Exception occures because MyProperty.value is always a String.
Can you maybe help me out with this last thing.
thx
|
|
|
|
|
Curse4Life wrote: TempObject.GetType().GetProperty(MyProperty.Name).SetValue(TempObject, MyProperty.Value, Nothing)
When you do this big long line of code you lose several useful things.
1. You lose the ability to debug easily in to part of the code. You end up stepping in and out of lots of things before you get to the bit you want.
2. You lose some readability because it becomes difficult to see what each part is actually doing and in what order.
3. You lose sight of what is going in and coming out of each part. Which means you cannot see the forest for the trees.
This bit:
TempObject.GetType().GetProperty(MyProperty.Name) should return a PropertyInfo . It will tell you what this bit:
MyProperty.Value needs to be changed to in order for it to work.
You must make the string into the type that the property expects.
|
|
|
|
|
Thanks for your answer but my question is exact how make this:
"You must make the string into the type that the property expects."
I have no idea how, because I have only the value in a string format and DirectCast expect a Type but if I say:
DirectCast(MyProperty.Value, TempObject.GetType().GetProperty(MyProperty.Name).PropertyType)
then Visual Studio shows an error at this line.
Other ideas?
mfg
|
|
|
|
|
There are hundreds of types in the .NET Framework. On top of that you can create a limitless number of types yourself. You will have to find a way to convert a string into the type needed.
You might want to take a look at the subject area of serialization and deserialization - it is probably your best bet. But if you already have constraints about how the string currently looks then it may not work for you.
If you have a limited number of possible types that you know about you can set up, say, a switch statement to perform specific actions depending on the type.
Curse4Life wrote: DirectCast(MyProperty.Value, TempObject.GetType().GetProperty(MyProperty.Name).PropertyType)
And for goodness sake, please make this more readable by spliting it up over several lines.
|
|
|
|
|
i am using AxMsFlexGrid.
now i want to display boolean data column as a checkbox ! how can i do that?
please reply .
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
I try to call SetParent window api.
I use this code:
Private Declare Function SetParent Lib "user32" _<br />
(ByVal hWndChild As Long, _<br />
ByVal hWndNewParent As Long) As Long<br />
<br />
Private Sub Form1_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br />
Dim lngStyle As Long<br />
Dim c As Object<br />
'Dim lngStatusBar As Long<br />
<br />
mobjXL = New Excel.Application<br />
mobjXL.Caption = "Main"<br />
<br />
mlngXLHwnd = FindWindow("XLMAIN", "Main")<br />
SetParent(mlngXLHwnd, Me.Handle)<br />
<br />
lngStyle = GetWindowLong(mlngXLHwnd, GWL_STYLE)<br />
<br />
lngStyle = lngStyle Xor WS_CAPTION<br />
lngStyle = lngStyle Xor WS_SIZEBOX<br />
<br />
SetWindowLong(mlngXLHwnd, GWL_STYLE, lngStyle)<br />
End Sub
When I call the function SetParent I got error:
PInvokeStackImBalance was detected
What is wrong in this line?
|
|
|
|
|
You are using Long but it should be Int32 ...
|
|
|
|
|
I change the parameter from Long to int32 but still got the error:
A call to PInvoke function 'EmbedManagedExe!EmbedManagedExe.Form1::SetParent' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Do you have any other idea how to solve the problem
|
|
|
|
|
How about...
<code>
Private Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Int32, _
ByVal hWndNewParent As Int32) As Int32
</code>
|
|
|
|
|
using your function declaration, I got the error:
OverflowException was unhandled.
I don't know whats wrong eith thus call?
Thanks for the help;)
|
|
|
|
|
Presumably your declaration for GetWindowLong are still using Long ?
Change this to Int32, and also change the variables you pass in to match.
|
|
|
|
|
If you wrote the declaration by hand than you may have a part of the declaration wrong. I would suggest that you google API Viewer and API Guide. These two programs give you both examples of how to use native WinAPI (API Guide), and the proper syntax for thousands of commands, structures, and constants (API Viewer). The information provided by the programs can be converted to a variety of languages (at least API Viewer, API Guide is all in VB but can be converted fairly easily to other languages).
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hellow Thomas
I didn't wrote the declaration by hand
The declaration was taken from ApiViewer
Declare Function SetParent Lib "user32.dll" ( _ <br />
ByVal hWndChild As Long, _ <br />
ByVal hWndNewParent As Long) As Long
|
|
|
|
|
Well even API Viewer has some problems. When dealing with any sort of window in .NET you can get the IntPtr handle of the window through the Handle property. You can pass the IntPtr value through the declarations and it should work. Try this:
<br />
Declare Function SetParent Lib "user32.dll" ( _<br />
ByVal hWndChild As IntPtr, _<br />
ByVal hWndNewParent As IntPtr) As Long
Another similar option would be to set the identifiers to Int32 instead of long and using the form1.Handle.ToInt32() method to convert the handle to Int32. Code for that declaration would be:
<br />
Declare Function SetParent Lib "user32.dll" ( _<br />
ByVal hWndChild As Int32, _<br />
ByVal hWndNewParent As Int32) As Long
Int32 is always the best alternative (in most cases) to use instead of the long identifier which (if I am correct) has been changed with how much memory it can store. One of my articles: Add Transparent Menus and XP Titlebar Buttons to your application[^], uses various API commands that use hwnd handles and you can see similarly how they are used and it may be able to help you.
Good Luck!
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hellow Thomas
I tried the both way, and the two ways were failed.
When the type is declare as IntPtr I got OverFlowException error.
I got the same error when the parameter was declared as Int32.
What you suggest the best way to continue?
Thanks;)
|
|
|
|
|
I will see if I can have a success when using the dll function and post back. All I have suggested has been from prior knowledge and not from me actually testing the procedure. I'll post if I succeed.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
I have found both your error plus a sort of conclusion. I used the code following to test the SetParent method. At first I was trying to move the start button and have its parent the window where I was working, however that resulted in a memory error and my losing of the start menu temporarily. I was able to, however, to use the SetParent method for actual windows that are visible on the desktop window.
To start off here is the code (quiet lengthy):
Public Class Form1<br />
'API Declarations<br />
Private Declare Function SetParent Lib "user32.dll" ( _<br />
ByVal hWndChild As IntPtr, _<br />
ByVal hWndNewParent As IntPtr) As Int32<br />
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _<br />
ByVal lpClassName As String, _<br />
ByVal lpWindowName As Int32) As Int32<br />
'API NOTE: When using the findWindow API command you can replace the indetfiers of<br />
'either classname or windowname to Int32 so that you can have an empty (0) parameter<br />
'similar to the null object in C# and C++.<br />
<br />
<br />
<br />
'Variables to store the handles of specific windows<br />
Dim apiViewerHandle As Int32 = 0<br />
<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
apiViewerHandle = FindWindow("ThunderRT6FormDC", 0)<br />
If apiViewerHandle = 0 Then<br />
'You always need to make sure that you have a windows' handle<br />
'if the handle is 0 then you do not have any control over the window<br />
MessageBox.Show(apiViewerHandle.ToString())<br />
MessageBox.Show("No handle can be found")<br />
Application.Exit()<br />
Else<br />
'SetParent(buttonHandle, taskbarHandle)<br />
SetParent(apiViewerHandle, Me.Handle.ToInt32())<br />
End If<br />
End Sub<br />
<br />
End Class<br />
<br />
This code I tested by setting the parent of the API Viewer window to that of my .NET applications' Form1. I first used the Visual Studio tool Spy ++ which allowed me to find out the class of the window that I was taking control of so that I could get its handle through FindWindow. I then set the parent of the form using the SetParent method, as said, to my .NET applciations' form. This scenario did work, at least for me, but I am not quite sure if will help in your exact situation since I do not know what window you are trying to take control of. My next guess would be to make sure that you have a handle of the window you want control over. Make sure the handle from FindWindow is not equal to 0.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Thanks for your help.
With your code example I success using SetParent function of ummanaged exe into managed form
|
|
|
|
|
www.pinvoke.net is my first call when I have pinvoke issues.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|