|
I have:
For i = 0 To 100
'TextOut GetWindowDC(GetActiveWindow), 50 + 10 * i, 50, str, Len(str)
RetVal = Rectangle(GetWindowDC(GetActiveWindow), 20 + 10 * i, 40, 30 + 10 * i, 50)
' ProgressBar1.Value = i
Next
on a modal form. Works ok. But, if you cover the running app with another screen and then show the app again, the rectangles have vanished!
I tried
' Form1.AutoRedraw = True , but this makes the form come up with no rectangles, and when you close the app, task manager says its still running. (I call that a 'crash' I dont know what that situation is called'.
Thanks,
ns
|
|
|
|
|
If you add your code to the subroutine Form_Paint() I think you should be able to see your rectangles when redisplaying your form. This worked for me.
Private Sub Form_Paint()
For i = 0 To 100
'TextOut GetWindowDC(GetActiveWindow), 50 + 10 * i, 50, str, Len(str)
RetVal = Rectangle(GetWindowDC(GetActiveWindow), 20 + 10 * i, 40, 30 + 10 * i, 50)
'ProgressBar1.Value = i
Next
End Sub
Nick Parker
So like children pointers should be left to grown ups. - Norm Alomond
|
|
|
|
|
Hi,
I've created a VB.NET application. I want that all exception generate an eventlog entry. I want also a specific eventlog so that it would be faster to find errors in logs.
I've written the code below. When running, all is ok (no error) but when I launch the eventlog console to have a look, I can see my eventlog but there is not entry in it.
<br />
' Create the source, if it does not already exist.<br />
If Not EventLog.SourceExists("OrthoDLL") Then<br />
Console.WriteLine(EventLog.LogNameFromSourceName("OrthoDLL", "."))<br />
EventLog.CreateEventSource("OrthoDLL", "Sybux")<br />
Console.WriteLine("CreatingEventSource")<br />
Console.WriteLine(EventLog.LogNameFromSourceName("OrthoDLL", "."))<br />
End If<br />
<br />
Dim myLog As New EventLog()<br />
<br />
myLog.Source = "OrthoDLL"<br />
<br />
' Write an informational entry to the event log. <br />
myLog.WriteEntry("Writing to event log.")<br />
thx for help
|
|
|
|
|
how do you set up shared memory in VB? How is this written to and read from. ARe the changes communicated instantaneously? I need some links or sample code showing this process.
|
|
|
|
|
Here[^] is a link on how to do this in VC6, do you have to do this in VB?
Nick Parker
So like children pointers should be left to grown ups. - Norm Alomond
|
|
|
|
|
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
|
|
|
|