|
Hi I'm currently trying to code a REAL-TIME midi remapper program in Visual C++ using MFC..
I need the program to constantly look for a input midi signal... The only way I have figured out how to do this is to run a constant loop that contains the midipoll(); I've had to set it to only recieve a certain number of signals so it will eventually end.
I works great and recieves all of the messages.. but while in this loop I loose control of the rest of the program... The loop takes over. Is their a way I can do this without loosing control of the program?
|
|
|
|
|
Put that processing into a secondary thread.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Thanks.. that worked out great using a work thread...
Now i'm having a problem accessing the UI from within the thread.. ie. a listbox
I need to send info to the listbox from within the thread.. Any Ideas
this is what I got...
UINT MyThread( LPVOID pParam ); //prototye
UINT MyThread( LPVOID pParam )
{
while(RunThread) {
If (inputdetected){
m_ListBox1.Additem("input detected"); // <-- I don't have access to ListBox 1 from withing this thread.
}
}
return 0; // thread completed successfully
}
I call the thread to start with..
AfxBeginThread(MyThread, NULL);
-- modified at 15:50 Thursday 6th April, 2006
|
|
|
|
|
You can not use the MFC control placeholders from the thread.
Instead, it is better to use the listbox control's window handle directly to add elements to the listbox.
The LPVOID pParam passed to thread could be a data structure, in that data structure, one of the fields could be the window handle for the list box control.
So you call
typedef struct {
HWND hListBox;
} MYSTRUCT ;
MYSTRUCT MyThreadInfo;
MyThreadInfo.hListbox = m_ListBox1.m_hWnd;
then
AfxBeginThread(MyThread, &MyThreadInfo);
UINT MyThread( LPVOID pParam )
{
MYSTRUCT* pMyThreadInfo = (MYSTRUCT*)pParam;
while( RunThread ){
if( inputdetected ){
SendMessage(pMyThreadInfo->hListbox, LB_ADDSTRING, 0, (LPARAM)"input detected");
}
}
return 0; // thread completed successfully
}
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
AWSOME!!!!! everything works perfectly using this method...
Thanks Blake
|
|
|
|
|
This is driving me nuts. I'm trying to call CreateProcess() to start Internet Explorer from within a Manifest-enabled (specifically Common Controls 6) application and I get about 7 dialog boxes that say the exact same thing:
------------------------------
Runtime Error!
Program: C:\Program Files\Internet Explorer\iexplore.exe
R6034
An application has made an attempt to load the C runtime library incorrectly.
Please contact the application's support team for more information.
['OK' button]
------------------------------
After I click through all 7 'OK' dialogs, everything seems to work normally.
The only thing that I've discovered searching Google is that XP Manifests for Common Controls 6 is what seems to be affecting Internet Explorer's startup sequence. CreateProcess() is acting like "if the process starting the new process is XP Manifest enabled, then the new process MUST ALSO be XP Manifest enabled." Now, I know there has to be a workaround because Explorer.exe is XP Manifest enabled and runs new processes all the time (including IE).
|
|
|
|
|
1) Use CreateProcess() to start another process besides iexplore.exe.
2) Remove the manifest from your project and then try to start iexplore.exe.
What does this uncover?
"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
|
|
|
|
|
I figured out what the problem was. Well, not EXACTLY what the problem was, but it had to do with sending an incomplete set of environment variables to the new process in the CreateProcess() call.
Thanks anyway. The error message had very little to do with the actual problem (which is what was so strange). Apparently IE relies on the Visual C++ libraries in some way that is dependent on the environment variables passed to it.
|
|
|
|
|
I need to know how to control a directory structure from the "Open" dialog window from an application. I need to be able to restict the user from going to directories that have been determined they should not enter and restrict them to a certain directory. Anyone have any idea how to do this not in MFC, win32 api format.
Thanks,
|
|
|
|
|
You can restrict them to a single directory using the OFN_NOCHANGEDIR flag. If you need something a little more complicated then create your own OpenFile dialog.
|
|
|
|
|
waldermort wrote: You can restrict them to a single directory using the OFN_NOCHANGEDIR flag.
Wrong. That flag restores the current directory to its original value if the user changed the directory while searching for files.
"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
|
|
|
|
|
Thanks for pointing that out, learn something new everyday :->
|
|
|
|
|
See here.
"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
|
|
|
|
|
the hard way would be hooking ZwQueryDirectoryFile and restricting your diretories.
:P
I'm sure there is an easier way
gabby
|
|
|
|
|
Here is the scenario.
I have a web based email client application I have created on a certain website. Whenever a user clicks on an email address, it will take them to this client and populate the TO field, and maybe even the subject field, depending on the mailto parameters.
I know I'd have to set my default client to this web based client. Does anyone know how to accomplish this or any direction I can be pointed to, to begin? What tools should I use?
-- modified at 16:39 Wednesday 5th April, 2006
|
|
|
|
|
I suspect you'd need to make a change to HKEY_CLASSES_ROOT\mailto\shell\open\command.
"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
|
|
|
|
|
Yea. I know you have to change the to open Internet Explorer and set it to the respective URL. However, how would you populate the form's fields?
|
|
|
|
|
One way is via the mailto: protocol itself:
mailto:tdnxxx444@codeproject.com?Subject=Test subject&Body=Test body
"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
|
|
|
|
|
How would I use the that populate the fields in my WEB BASED email client that I wrote though?
|
|
|
|
|
It looks as though I spoke too soon. You may have to resort to some .vbs, .wsh, or .js file to do this for you.
"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
|
|
|
|
|
Okay. Where would the above file you mentioned be locationed? On my website with the email client?
I looked at how they do it for the hotmail client that is built into internet explorer and it seems to use a DLL file. Would this way be easier or the way you mentioned?
This is basically how the flow of events should look so that we are on the same page:
user clicks on mailto hyperlink in their browser ->
another internet explorer opens up and takes them to our website email client application ->
form is populates TO: and SUBJECT: fields based on the paramaters of the mailto hyperlink
I guess I am confused as to how the "mailto" hyperlink would communicate to internet explorer and to our website that the user is taken to, these respective parameters.
|
|
|
|
|
tdnxxx444 wrote: Okay. Where would the above file you mentioned be locationed? On my website with the email client?
Ignore my earlier suggestion.
tdnxxx444 wrote: I looked at how they do it for the hotmail client that is built into internet explorer and it seems to use a DLL file.
I'm sure that IE uses dozens of DLL files. That sort of goes without saying.
"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
|
|
|
|
|
hey, I am almost certain that the problem with my dll at this point is an access violation caused by writting to a file. I have stripped out all other code but that, and it fails, I strip out just that and the rest succeeds. So, I know it is with the writting to the file, which is causing an access violation.
I placed returns strategically through out the source and I know that it is behaving accordingly as planned and should not cause a violation, however, it is.
I have a setup similar as follows:
while (blah is blah) { // run till judgment day
out = fopen("test.txt", "a");
for (blah = 0 to length of header) { // loop till blah equals header length
fprintf(out, some data)
}
fclose(out);
} // end while
and that is pretty much it, in a nutshell. The problem is unknown to me, because this works fine in an exe I built --I am trying to port my code to dll.
I am starting to think that I can NOT work with a dll like I could a VB module. It seems the minute I start to write to the file, it will loop through the for 5 times and then crash, if I don't loop, it will write one time just fine.
I hope that I haven't explained all help away and that my question is clear. I need to find out why I can not continously write to a file from a DLL. Why it is causing an access violation, per debug. And what I can do to fix it or if I should stop trying to do the impossible --I assume at this point that this is impossible to accomplish from a DLL.
If you need more info, please let me know. I thank you in advance.
-- modified at 13:41 Wednesday 5th April, 2006
bold = modified
|
|
|
|
|
borono wrote: out = fopen("test.txt", "a");
Why are you opening the file in the while loop?
borono wrote: I hope that...my question is clear.
Given that you did not show the exact code that is causing the problem, it's going to be hard to offer any real help.
"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
|
|
|
|
|
Without seeing your real code, ie. without all the blah's, it's gonna be a little hard to find your problem. But one thing does stand out. Each time you loop, you are opening the file, then you close it after the loop. This is an uneven ratio of open/close. You should really open the file before the loop, do the wrinting inside the loop, close it after the loop.
|
|
|
|