|
Both - its a VB dll sending info to a VC client. HAd trouble with getting senmessage etc to work.
Thanks,
ns
|
|
|
|
|
Perhaps knowning exactly what you want to "share" would help out more. Depending on the kind of data and its nature, there may be one or more solutions to your problem.
- (i think i swallowed a bug)
"there's more to life than skiing, when you find it let me know"
|
|
|
|
|
I have written an MFC ActiveX control in VC++7 and am testing it in Excel 2000.
For some reason Excel will not recognize any methods of the control that were
added to the control after the very first time I used it in Excel. Even in a completely new spreadsheet. The new methods show in the object browser of Excel/vba but generate a "runtime error 438 (Object doesn't support this property or method)" error when called in the vba code.
I've tried unregistering the control, removing it physically, removing references to it but all to no avail.
If I try all of the above in Access 2000 using VBA it works fine.
Is this an Excel bug of some kind or...?
|
|
|
|
|
The VB dll has in a function:
result = SendMessage(PbarHandle, 1026, 5, 0)
The VC client sends in the handle of a progressbar. I verfied that handle sent in is being received by the VB dll. However if I put a msgBox right after the SendMessage , it doesnt fire. In the VC client, at the call to the dll, a com error happens:
void CMswayView::OnButton2()
{
try
{
CoInitialize(NULL);
_Class1Ptr ptr;
ptr.CreateInstance(__uuidof(Class1));
m_Progress1.SetStep(1);
m_Progress1.SetRange(1, 10);
long lHwnd=(long)m_Progress1.GetSafeHwnd();
ptr->CheckingStuff(&lHwnd);
}
catch(_com_error &e)
{
bstrDesc = e.Description();
}
CoUninitialize();
}
But we know the error is happening in the VB dll since the we cant get past the sendmessage, and the very next line: msgbox doesnt fire.
How can I figure out what is happening? Why is sendmessage not working? Is it that I've done something dumb in sending in the handle and its not valid anymore or something?
I have a #import in my VC client for the VB dll.
Thanks,
ns
1026 is just setting the position. Not even 1029 (PBM_STEPIT) works. Somethigs fundamentally flawed in my assumptions here...
|
|
|
|
|
Show me how you declared SendMessage (hint: in VB6 you used Long for Window Handle. In VB.NET you need to use Integer)
|
|
|
|
|
Private Declare Function SendMessage Lib "User" (ByVal hWnd As <code>Long</code>, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Long) As Long
I changed it to ByVal hWnd As Long , it was originally integer from the msDN. But it still doesnt work.....
The msgbox doesnt fire,
result = SendMessage(pBAr, 1029, 0, 0)
MsgBox result
The VC client gets a com error at runtime (goes into the catch(com e) block) is:
sway.exe (KERNEL32.DLL): 0xC000008F: Float Inexact Result.
Desperate!
|
|
|
|
|
I did
Private Sub Command1_Click()
Timer1.Interval = 40
Form2.Show vbModal
End Sub
Private Sub Timer1_Timer()
Dim rc As Long
Dim opstr As String
opstr = "fff"
rc = TextOut(Form2.hdc, 6, 20, opstr, Len(opstr))
Timer1.Interval = 0
End Sub
and was trying to step into. After timer1.interval I expected the execution to g into the timer function, but it didnt and just showed the modal form instead.
But a msgbox in timer function does trigger so i know its going in there> But it totallly disregards the textout and i dont see anything on form2. Doesnt textout "force" write stuff to where you say to write?
Thanks,
ns
|
|
|
|
|
This should work:
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Sub Command1_Click()
Dim str
str = "This should work"
TextOut GetWindowDC(GetActiveWindow), 50, 50, str, Len(str)
End Sub
HTH
Nick Parker
So like children pointers should be left to grown ups. - Norm Alomond
|
|
|
|
|
This is amazing! It worked! Many many many thanks!
Thanks,
ns
|
|
|
|
|
Hi,
Is there any plugin already released that allows me to use the VS.NET IDE to program in Pascal?
Thanks
|
|
|
|
|
DOH!
Not as far as I know... there might be a version of Delphi for .NET soon but I don't think that it will use the VS IDE.
|
|
|
|
|
I'm doing the following in a standard VB exe:
Private Sub Command1_Click()
Dim rc As Long
Dim opstr As String
opstr = "kk"
Form2.Show
rc = TextOut(Form2.hdc, 6, 20, opstr, Len(opstr))
End Sub
Nothings on form2!!!! What am I doing wrong?
Thanks,
ns
|
|
|
|
|
I need to dismiss a modal form (HAS to be modal by limitation of my circumstances). Then I want to update progressbar info in it, then reshow it. unload doesnt work. Form sits there stubbornly...ANy way to kill it?
Thanks,
ns
|
|
|
|
|
Have you used the visible , or hide property I think it is? Which way are you referencing your form, are you using Unload me or Unload form1 ?
Nick Parker
So like children pointers should be left to grown ups. - Norm Alomond
|
|
|
|
|
Unload form1 because its being done in a class function, so I didnt think I could use me. Hide and Unload wont work. It needs manual intervention. I abandomned that idea and doing sendmessage instead.
BTW, what is the counterpart of an MFC HWnd? I am sending in a handle to a window from VC to the dll so it can sendmessage back. Whats my VB function parameter to be? MyVBFunc(HandleFromnVc as ?)
Thanks,
ns
|
|
|
|
|
I think you can pass it as a Long .
Nick Parker
So like children pointers should be left to grown ups. - Norm Alomond
|
|
|
|
|
I have the following in vs sp5:
Public Function CheckingStuff()
'MsgBox "a"
Form1.Text1.Text = "didstuff"
Form1.ProgressBar1.Visible = True
Form1.Show vbModal
'MsgBox "just showed form1"
For i = 0 To 100
Form1.ProgressBar1.Value = i
i = i + 1
Next
Form1.ProgressBar1.Visible = False
End Function
the progressbar shows up blank. What am I doing wrong?
Hellpp!!!
Thanks,
ns
|
|
|
|
|
1) Why are you incrimenting 'i' inside the loop that is also incrimenting 'i'?
2) Place a doevents inside the loop to give the screen a chance to update.
|
|
|
|
|
I think the problem is that I show the form as modal. So it doesnt get dismissed automatically and get reloaded with the next update? The VC client can only show the dll form as modal (by design according to MS), so I have no choice. So if I preset the progressbar value to 50% OUTSIDE the loop, it shows , but the updates dont show, even with doEvents. I might have to "force" draw a progressbar (two rectangles) onto the modal form with something akin to textout ?
The other option I have is to send in the callback functionpointer into the VB dll so it can callback the VC app and notify it of its progress. only thing is, how do I call this function from within VB?
eg if my VC app says:
ptr->MyVBFunction(& VCCallBAckFunction)
Then how will VB call this function? I do a #import in my VC side to let VC know I'm using this VB dll. But what should I tell VB about who the calling app is?
Thanks,
ns
|
|
|
|
|
I don't believe DoEvents is what you will want to call here, I think you are going to want an API call to UpdateWindow(form1.Hwnd).
Nick Parker
So like children pointers should be left to grown ups. - Norm Alomond
|
|
|
|
|
The problem is not with the loop or doevents. When you open a form in vbmodal then the program execution stops till the window is closed. This has to be used for showing some alert or message where user. Either use vbModeless or else use a timer control to increment progress bar value.
dsk
|
|
|
|
|
i wanna a feature to catch the keydown in WORD for sometimes some char should be change to other char (don't use autocorrect in WORD).
Can VBA catch this event? I browse the help of VBA in WORD, but don't see anything useful?
May you lend me a hand?
|
|
|
|
|
I have a VB.NET application that runs all the time in a custom Kiosk my company builds. I'd like to be able to shutdown and then restart our application remotely. We use Remote Administrator for this now, but there's a lot of them so when I have a need to do things like this I'd rather not do it manually. So, I wrote a Service that runs in our Kiosks. Since our units are equipped with an FTP server, my service simply looks for an XML file to show up in a certain directory. The XML file contains a list of "commands", one of which is to shut down our software. In looking in how to shut down another process I looked at the System.Diagnostics.Process namespace and wrote this:
from within "Main":
Dim ProcessHandler As New System.Diagnostics.Process()
If (FindRunner(ProcessHandler)) Then
ProcessPath = StopRunner(ProcessHandler)
End If
' Functions
Private Function StopRunner(ByVal Process As System.Diagnostics.Process) As String
Dim ProcessPath As String
ProcessPath = Process.MainModule.FileName
Process.CloseMainWindow()
Process.WaitForExit(3000)
If Not Process.HasExited Then
Process.Kill()
End If
Return ProcessPath
End Function
Private Function FindRunner(ByRef Process As System.Diagnostics.Process) As Boolean
Dim colProcess() As System.Diagnostics.Process
colProcess = Diagnostics.Process.GetProcessesByName("TEC_Runner")
If colProcess.Length > 0 Then
Process = colProcess(0)
Return True
End If
Return False
End Function
The Kill() was added later when I realized that CloseMainWindow() wasn't working for me from within the Service. Debugging a service is kind of a pain, so I first wrote the code as just another VB.NET application and this worked great every time. However, when I moved the same code into the Service, the WaitForExit() never returned (I didn't specify any milliseconds at first which of course meant it locked up). I don't understand why it works every time from within a normal application, but NEVER succeeds from within a Service. Do I need to do this some other way? Any ideas what's going on? Using Kill() works... mostly... but it rips the application down without letting it cleanup (and it does important things when being shut down normally that I need it to do). Please help!
Thanks!
Matt Philmon
|
|
|
|
|
Its necessary for me to launch a form in my COM VB dll. So far all I have in it is a class, and a bas module.Launching the form can be the first thing the dll does - it will be a progressbar indicating the progress of my dlls called function. Then I want to make it vanish when the dll is done with its job. Please help!
Thanks,
ns
|
|
|
|
|
I guess I am not sure where you are stuck.
Nick Parker
If the automobile had followed the same development as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year killing everyone inside.
-Robert Cringely
|
|
|
|