By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

Why does Excel not want to open within a panel?

P: n/a
It takes a lot for me to give up on finding the solution and for this I've finally reached that point. I have a program that opens a few other programs (PowerPoint, Excel and mIRC) and runs each one inside a panel on the form. I'm having no issues with PowerPoint or mIRC. Excel was working for a bit and now just doesn't work. Here is my code:

Expand|Select|Wrap|Line Numbers
  1. Private Const WM_SYSCOMMAND As Integer = 274
  2. Private Const SC_MAXIMIZED As Integer = 61488
  3. Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild as IntPtr, ByVal hWndNewParent As IntPtr) As Integer
  4. Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal IParam As Integer) As Integer
  5. Dim proc3 As System.Diagnostics.Process
  6.  
  7. Private Sub LoadTracker()
  8.  
  9.   proc3 = System.Diagnostics.Process.Start(NameOfMyExcelFile)
  10.   proc3.WaitForInputIdle()
  11.   SetParent(proc3.MainWindowHandle, Me.TPanel.Handle)
  12.   SendMessage(proc3.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
  13.  
  14. End Sub
  15.  
I have a button on the form which launches LoadTracker.
Oct 29 '10 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Yes, I do realize I wrote SC_MAXIMIZED in the Private Const line and then have it as SC_MAXIMIZE below that. It was right in the actual code.

Anyway I figured it out. I had the SetParent line and the SendMessage line swapped. I put them back in the right order and it worked again.
Oct 29 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.