|
Hi Borono,
Sorry I didn't get chance to answer your E-mail yet. I was going to suggest running your dll in a thread, though it looks like you figured it out already. The only problems you may encounter is alerting the VB side about events happening in the thread.
I'm not sure how VB handles handles a message loop, or if there is one, but I would suggest creating a GetMessage() function in your dll which the VB can constantly call. Thus retrieving any notifications from the thread and acting on them.
|
|
|
|
|
thanks waldermort, that sounds like a good idea, GetMessage(). I actually tried using a separate function, which of course didn't work. I am trying. Yes, I think multi-threading is the answer here as well, I have a bit of research to do. thanks again and no worries about the email, I got up early today, am sick with nothing better to do and started stirring a bit, thought I would get going on it. Glad you jumped in. I think I am just upsetting the other gentlemen.
best regards
|
|
|
|
|
You were not upsetting me. I was already upset. Sorry if I came across gruff.
|
|
|
|
|
no problem my friend, no harm done. In fact, your suggestion on callbacks was quite successful. Just in case anyone needs the same, here is how you perform the callback from DLL to VB.
First you need to write the DLL. Create the new project, "simple project". Then paste this code:
extern "C" void __stdcall TestCallback( void (*cb) (int*) )
{
int nrMsg = 123 ;
cb( &nrMsg );
}
Create a def file and place this in it:
LIBRARY MYDLLNAME
EXPORTS
TestCallback @1
Note: you have to do this for VB, also notice the _stdcall, again a must for VB.
Then compile the DLL and place in the VB project directory.
Create a new VB project and add a module and command button.
In module:
Option Explicit
'
Declare Sub TestCallback Lib "mydll.dll" (ByVal funcptr As Long)
'
Sub CallbackFunction(ByRef numb As Long)
MsgBox "Success: " + Str(numb)
End Sub
In form:
Private sub Command1_Click()
TestCallback AddressOf CallbackFunction
end sub
Now compile the project and run. Should return 123.
gdlk, hope this was clear. now off to multi-threading. thanks
best regards
-- modified at 23:42 Friday 7th April, 2006
Update: multi-threading complete. I did what you said and it works great, can start and stop it at will now, easier than I thought it would be. thanks a lot.
this is solved, regards
|
|
|
|
|
Hello,
Does anyone have any experience with using or creating alternative shells for Windows 2K, XP ??
Basically, my question is I want to know how simple or complex it would be to have Winlogon run my program instead of Explorer, so that my program can do some things, and then turn around and launch Explorer as the main shell.
I have found a registry key that looks like it might be a simple way to launch my program:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
This key contains a value called "Shell" that currently says "Explorer.exe". Do you think that all I have to do is replace that value with my program, or do you think I have to develop a custom GINA dll and all that stuff?
Any thoughtful comments would be appreciated,
Rich
|
|
|
|
|
|
I receive event 1,
I would like to set a timer to the millisecond
When i receive event 2,
I would like to stop that timer.
Anyone know what i should use?
Also, if i decide to get the current time to the millisecond after the 1st event, then do the same for the second event.
Then i can subtract the two and get the difference in time
Anyone know how to do that as well?
|
|
|
|
|
SetTimer() would send you WM_Timer messages, but handling this with a resolution of (less than) a millisecond is asking a bit much.
If you can afford to rely on DirectX, timeSetEvent() would be the way to go.
It provides you with the possibility to be called with a much higher accuracy.
Measuring even shorter durations is easy:
You ::QueryPerformanceCounter() on event1.
You ::QueryPerformanceCounter() on event2.
The difference is your duration between the events.
Be sure to ask ::QueryPerformanceFrequency() about if and with which frequencies the timer runs.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
This question has been asked and answered many times. What is it that you are not understanding?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
This previous response was the only response that gave me something to try to the nearest millisecond. Other responses, simply said that this cannot be done to accuracy with a windows OS. I have looked at a few other API calls but they all give time to the nearest second..
This current response gave me (QueryPerformanceCounter) to try that i had never tried to achieve millisecond time...
|
|
|
|
|
hi, can somebody help me to determine the source code for chain code?
|
|
|
|
|
what is chain code ?
what is it supposed to do ?
|
|
|
|
|
|
Hi there,
I receive some data as packets in XML format and I need to verify thier type for further implementation, and I can understand what kind of data I am dealing with as I need to send the data to different palces through socket (for example: if the data I receive is transaction request, send it to that bank through IP add ......., if data is sign on send it to host,....). Is anyone know how I can do it?
TNX
nahitan
|
|
|
|
|
I am working on an application which will going to use OpenGL in 2 different locations.
#1. in DialogBar
#2. in CView
I implemented OpenGL for both, and they are working well when one of them is disabled. My problem is when both are active, confliction happens like they are trying to use opengl setup properties of each other like..if Dialog is wireframe CView turns into wireframe mode then crashes..
How can I prevent this, and let them work without touching each other.is Multi-threaded 2 different engine needed? ( As the example I gave above..they are using different views so I cant use 1 engine for both view. )
I am missknowledged about this type of OpenGL problems..
Any suggestion, articles are all welcome...and I ll be very glad...
thanks...
|
|
|
|
|
Hi all,
I'd like have some MDI child windows (Form View) like model dialogs, so that after closing the dialog only, I should even be able to access the main window (toolbar/menu/close button).
How to make it possible?
Thanks in advance,
Sarvan AL
|
|
|
|
|
So - what you want is a modal dialogue with a FormView(-derivation) inside?
There should be a few examples lying around here on CP.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hi, is there any VC++ add-in to automate variable/class renaming ?
|
|
|
|
|
on't know any for C++, but you could search for refactoring to get more answers...
|
|
|
|
|
Its called RefPP[^]and works quite well as my limited testing showed.
Also, the guys at refpp.com are quick with help and service.
All in all a fine tool!
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Some time ago I happened upon an article (or maybe just a program )- with source code in C++, almost certainly MFC - implementing graphically a New York City/Manhattan path algorithm: that is a orthogonal polyline each of whose points' moves were constrained to the X and Y directions.
I think I saw it here on The Code Project.
Can somebody please point me to it?
TIA
alex
'Architecture is music frozen in space.'
|
|
|
|
|
|
Thank you for answering, but no.
It was either MFC or WIN32 (before C#, .net etc)
What I do remember, the demo drew a polyline (orthogonal segments only) and allowed the user to move those points while keeping the orthogonality.
alex
'Architecture is music frozen in space.'
|
|
|
|
|
Hi - I don't usually like to post questions which are "here's some code - why doesn't it work?" but I am well and truly stumped on this one...it's been more than a whole day's effort so far and it is 1025 on friday night and i'm still working on it....so i'd really appreciate some help...
I have two functions, one takes a buffer, turns it into PGM format (P6) and saves it to file....the other takes the buffer, turns it into PGM format in place and the calling function then returns the buffer and it is displayed
the saving to file one works a treat
<code>
/*
* writes a colour PGM file from a buffer
*/</code>
<code>
int write_P6(char *name, int W, int H, unsigned char *buf)
{
FILE *f;
int i, j;
if( (f = fopen(name, "w")) == NULL)
{
printf("Could not open >%s<\n", name);
return FALSE;
}
fprintf(f,"P6\n %d %d\n 255\n",W, H);
fflush(f);
for(i=0;i<H;i++)
{
for(j=0;j<W;j++)
{
fwrite(buf + (i * W + j)*3+2, 1, 1, f);
fwrite(buf + (i * W + j)*3+1, 1, 1, f);
fwrite(buf + (i * W + j)*3 , 1, 1, f);
}
}
fclose(f);
return TRUE;
}
</code>
and I am able to display the images just fine, but obviously this is sub-optimal and the disk accesses makes it real slow
so i want to use this function instead
<code>
/*********************************************************************/
/*
* changes a rgb buffer in place into PGM format without saving to disk
*/
int make_P6(int W, int H, unsigned char *buf)
{
int i, j;
unsigned char* temp;
temp = (unsigned char*)malloc(x * y *3+15);
sprintf(temp, "P6\n %d %d\n 255\n",W, H);
for(i=0;i<H;i++)
{
for(j=0;j<W;j++)
{
sprintf(temp, buf + (i * W + j)*3+2);
sprintf(temp, buf + (i * W + j)*3+1);
sprintf(temp, buf + (i * W + j)*3);
}
}
buf = (unsigned char*)realloc(buf, x * y *3+15);
buf = temp;
free(temp);
return TRUE;
}
</code>
the calling getframe function looks kinda like this:
<code>
unsigned char * getframe(int save_file)
{
int ret ;
ret = read(fd1, s, x * y);
if( ret != (x * y ) )
{
printf("We will have fragmented picture\n" );
}
nb_frame ++ ;
bayer2rgb24(d, s, x, y);
// at this point we should have a raw, RGB image
if( save_file )
{
write_P6("P6.pgm", x, y, d);
}
else
{
d = make_P6(x,y,d);
}
return d;
}
</code>
and the function which calls getframe knows whether to disregard the return value and open the file, or look at the return value for the pic....
now the problem comes in make_P6 --> the code just hangs at
<code> sprintf(temp, buf + (i * W + j)*3+2);
sprintf(temp, buf + (i * W + j)*3+1);
sprintf(temp, buf + (i * W + j)*3);</code>
- if i comment out these lines, there is no freeze (but clearly, nothing sensible happens to the image)....but if i leave them there, it just kinda waits....doing nothing....not crashing.....not taking up heaps of resources
it doesn't make any sense to me because the line
<code>sprintf(temp, "P6\n %d %d\n 255\n",W, H);</code>
works just fine....
i'll be eternally grateful if somebody can give me a hand
XX georgia
-- modified at 8:40 Friday 7th April, 2006
|
|
|
|
|
georgie.moss wrote: sprintf(temp, buf + (i * W + j)*3+2);
sprintf(temp, buf + (i * W + j)*3+1);
sprintf(temp, buf + (i * W + j)*3);
Of these three statements, only the last one is of any use since they are all writing to the same address. Is this your intent?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|