|
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
|
|
|
|
|
Sir/Madam,
I have two forms named form1 and form2.There is a button in form1.
On clicking the button in form1 , I am creating the object of form2 and opening the form2 and along with this i am closing the form1.But this closes the form2 as well.
I wanted to open the form2 and close the form1.Please help.
Thanks and Regards
Pankaj
|
|
|
|
|
Hi,
Here what is happening is the application main thread executed is calling the form1 to show and you are programatically calling the form2 to show and making the form1 closed so what happens the object of the form1 will get disposed right, due to this the application is completly closed Instead of this you can go for Me.Hide() to hide the parent form.
|
|
|
|
|
Possibly you are not resetting the line count or page number variables when the already previewed job is printed? You should consider doing this in the BeginPrint even so it gets done no matter how many times a print is done.
|
|
|
|
|
Thanks Duncan. im going to check that out and get back to u if thats ok .
|
|
|
|
|
Hi Duncan.
I was able to reset page number and lines filled counts but now it falls into a loop where the page number keep counting continously when PRINT PREVIEW OPENS and its goes into GENERATING PREVIEWS DIALOG PRINT PREVIEW.
we are so close .. I hope you can kindly tell me what it is im overseeing.
Kind Regards
Robbo
|
|
|
|
|
OK - are you resetting the line numbers in the BeginPrint event handler rather than the PrintPage event handler?
The former is called once when the print job starts whereas the latter is called once for each page you print until HasMorePages is set to false.
There's a (not quite tidied up) article on my website[^] that might be of help.
|
|
|
|
|
hey duncan. when you say line numbers are you saying LINES FILLED.. if so then yes i am resetting that in BEGINPRINT. Its definitely something i need to reset but can't seem to locate it. Just quickly and once again. everything in print preview is perfect. I see the data and layout drawn perfectly and page numbering including HASMOREPAGES count perfectly. but when i hit the PRINT BUTTON inside PRINT PREVIEW it only prints the last page. e.g. 3 pages in print preview ONLY PAGE 3 is printed.
If I only draw 1 page in print preview its of course draws the first which of course is also the last not to mention the only.
I really really appreciated your assistance on this. and if you like i could email or post the code for you with screen shots aswell.
Thanks a million
Robbo
|
|
|
|
|
If it prints OK if you don't preview it first then there is definitely something that needs to be reset in the BeginPrint event and isn't being reset...
e.g. in this article[^] the variables _CurrentLine and _CurentPage need to be reset in the BeginPrint event handler.
|
|
|
|
|
Duncan.
Just to clear up one thing. Its doesn't print OK if i don't preview either though. Both straight print and preview print act the same way. if it's ok my next reply to you will include my code.. and im sure you'll be able to say GOT IT!!! DO THIS....
Thanks Dunc. Talk again shortly after you read my code.
Robbo
|
|
|
|
|
Hi Duncan. Great news. After you've gave me point of looking and resettings counters etc. I found what and where my problem was. It was where i was calling and loading data. Intially I had data being called outside BEGINPRINT
and as soon as called it from inside BEGINPRINT , the problem was solved.
Thankyou so much for telling me what and where I should be calling and resetting. I appreciate it so much.
Regards
Robbo
|
|
|
|
|
Here is what I have in the collapse treeview
Private Sub TreeView1_BeforeCollapse(ByVal sender As Object, _
ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeCollapse
e.Node.ImageIndex = 0
e.Node.SelectedImageIndex = 0
End Sub
I load the treeview no problem, C and D drive have the drive icons, if I click plus next to drive C, I get all the folders on drive C (with folder closed icons) If I click the + next to a folder I get the open icon folder, and all the pictures with (picture icons) appear in the Listview.
So far So Good.
The Problem
When I close the pics folder the icon changes to a drive icon? if I then open another folder the pictures that appear in the listview are all over the place, I've figured if I change the ImageIndex numbers in BeforeCollapse then that's the icon that shows when a folder is closed, so I think I need something like
If ImageIndex = 2 then make it 1
If ImageIndex = 0 then keep it 0
and I figure I also need to clear the listview so that it can be repopulated in order
I've gone as far as I can with this and I'm sure the answer is something simple but, like looking for wood in a forest, I seem to be missing the obvious?
|
|
|
|
|
Anybloodyid wrote: If ImageIndex = 2 then make it 1If ImageIndex = 0 then keep it 0
This should work to get the right messages. As for the listview, it's indeed a good idea to clear the items collection (not the main clear method on the listview itself).
In conclusion: I don't tihnk you have a problem here
WM.
What about weapons of mass-construction?
"You can always try to smash it with a wrench to fix that. It might actually work" - WillemM
|
|
|
|
|
Here's the cure for the listview, placed in Private Sub TreeView1_AfterSelect(By
<br />
' Clear listview and reset view type<br />
ListView1.Clear()<br />
ListView1.View = View.Details<br />
'Create the columns.<br />
With ListView1.Columns<br />
.Add("Name", 120, HorizontalAlignment.Left)<br />
.Add("Ext", 40, HorizontalAlignment.Left)<br />
End With<br />
And the cure for the node icons?
well I just deleted all references to
ImageIndex and SelectedImageIndex
So a good result all round
|
|
|
|
|
hi
i want a table in sql server with 1500000 records and i use from datagridview for see them but speed of run it is very low .
please help me
|
|
|
|
|
Nobody is going to scroll through that number of records on the screen so you need to give them an interface that allows them to select the records they want and only then retrieve them from the database.
|
|
|
|
|
fatidarya wrote: i want a table in sql server with 1500000 records and i use from datagridview for see them but speed of run it is very low .
Just think about the quantity of data you are pulling across the network.
Assuming each row was one byte, you have requested 1.5Mb of data. Lets find a more typical example and assume you have an id (4 bytes), an 8 byte column (for a date maybe), a 20 btye column (a name maybe), and a 2 byte column (some code). Total 34 bytes of raw data per row not taking into account any overheads for the transmission of that data. That is a total of 51Mb. That would take a few seconds to pull that off a disk, format it for transmission, transmit it, parse the stream on the client, store it in what ever data structure you are using and then render it on the screen.
You should consider filtering the data so that the resultset is more relevant.
|
|
|
|
|
After searching through the Registry a bit, I found a key that controls the paths to each Control Panel icon (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Extended Properties\{305CA226-D286-468e-B848-2B2E8E697B74} 2 ). So I did a bit research to see if I could manually add my own icons my creating a sub key there, but I didn't find much. I did find something though saying you could only use .cpl files, because otherwise the icons would not show. Is this true? Because TweakUI is an application, not a .cpl . And, is it safe to add icons to the Control Panel by creating a a single Registry key?
Thanks a lot!
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
I'm able to use the string.replace function. Now I want to report on how many replacements have been made.
The below code makes the correct replacement, but I want to get a little feedback.
Dim strStartString As String = "To*All*The*Girls*I've*Loved*Before"
Dim strDestString As String = txtDestination.Text
strDestString = strStartString.Replace("*", " ")
txtDestination.Text = strDestString
Thanks!
|
|
|
|
|
All you'd have to do is use a For statement, then read to each "*".
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Sure, that would work. I'm sure that there is also different function that could search for how many "*" exist.
My first preference is to get the count of replacements by the function.
|
|
|
|
|
MatrixCoder's method is probably the most common technique and I do not think there is a method that is going to give this to you. If you are intent on pursuing a single method call then try this.
Dim Integer counter=strStartString.Split("*").Length-1
I kind of agree with MatrixC's technique since it is very discriptive of what it is doing.
|
|
|
|
|
Can you send to me some example written by VS.NET 2003?
Please send to address mail mrtrung04@yahoo.com or trantrung@imct.com.vn
Thank you very much!
|
|
|
|