|
Christian Graus wrote: Why on earth did you post all this code ?
No offence meant, but surely you have noticed the normal response when someone asks for help, but does not post the code that is giving problems / does not do what they want / etc?
I think posting the code shows how he is doing things so far, so we can tell him the most appropriate way to do what he wants to do.
|
|
|
|
|
No, he posted a class that he copied from the web. If it was his code, I would not have said anything. And it's not a complete class, you can't tell how images are stored in it, although I suspect a COM object.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Don't you ever sleep? How can you always respond in minutes, no matter what time anyone posts?
I see your point. But if he hadn't posted the code, someone would have replied "if you don't post your code, how can you expect anyone to help?" And then he would have posted it, etc.
|
|
|
|
|
Hi, I have to create a thread that read a hardware port less than 60ms. so I create a thread with TIME_CRITICAL_PRIORITY, but it would help. Is there any advice?
Thank you
|
|
|
|
|
I think you also need to use SetPriorityClass(...).
BOOL SetPriorityClass(<br />
HANDLE hProcess,<br />
DWORD dwPriorityClass<br />
);
Set dwPriorityClass = HIGH_PRIORITY_CLASS;
And set the thread priority around: THREAD_PRIORITY_HIGHEST or THREAD_PRIORITY_ABOVE_NORMAL .
If you set it to THREAD_PRIORITY_TIME_CRITICAL , then your program might miss hard disk writes!!!. It can also hang the system.
this is this.
|
|
|
|
|
Hello,
In window's, you can never know at what frequency your get a timeslice. You can say to windows that your thread is the most important one in the system by settings the priority class[^] and the thread priority[^]. You can safely set them to any value except the maximum. This might hang the system.
In that case, you should create an other small program that contains only your thread. You can lock this thread ot the desired time and suspend it when you get more time than you need. This way you won't dry up the CPU resources..
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hi, I need to detect the color of some pixels in another application running on my desktop. I am able to retrieve the DC of the window just fine when it is the top window, but can't when it is hidden behind another window! Is there a flag I can set or any other way for me to retrieve the color of a pixel on the application window if it is not directly visible to the monitor? i.e. if portion of the window is covered by another window, that new window's display is instead included in the DC I retrieve.
Currently I am using:
CDC *windc = window->GetDCEx( NULL, DCX_PARENTCLIP );
Where 'window' is a handle to the CWnd of the application window. Also I'm not sure that I require the DCX_PARENTCLIP flag -- I don't entirely understand the descriptions provided for the flags for GetDCEx.
Thanks in advance for your help!!
Jeremy.
|
|
|
|
|
Jeremy Pfund wrote: Is there a flag I can set or any other way for me to retrieve the color of a pixel on the application window if it is not directly visible to the monitor?
no, because screen DCs don't actually store pixels.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
You could try sending a WM_PRINT or WM_PRINTCLIENT message to the window. Not all widows handle those messages, but yours just might.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Hello,
I would like that users be able to launch my application from the Shell "Open with" menu.
Can somebody explain how to achieve that?
Thanks
|
|
|
|
|
See here.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hello,
Thank you for replying. I followed your link.
But I've already call EnableShellOpen in the CWinApp::InitInstance. And my application is listed under "Open with" menu.
When I open a file with the "Open with" menu, the shell actually launch my app. However I don't know how to do further processing like retrieving the file being launched and open it.
Can you help me doing that?
|
|
|
|
|
Allad wrote: However I don't know how to do further processing like retrieving the file being launched and open it.
I'm assuming you have either an SDI or MDI application. Yes? If clicking on a particular file opened your application, then the file is already opened and its name can be obtained from the document's GetPathName() method.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
Hello,
Thank you for replying. I followed your link.
But I've already call EnableShellOpen in the CWinApp::InitInstance. And my application is listed under "Open with" menu.
When I open a file with the "Open with" menu, the shell actually launch my app. However I don't know how to do further processing like retrieving the file being launched and open it.
Can you help me doing that?
|
|
|
|
|
Hello,
Thank you for replying. I followed your link.
But I've already call EnableShellOpen in the CWinApp::InitInstance. And my application is listed under "Open with" menu.
When I open a file with the "Open with" menu, the shell actually launch my app. However I don't know how to do further processing like retrieving the file being launched and open it.
Can you help me doing that?
|
|
|
|
|
Hi all,
I need to know that when i create a function, say:
int add(int,int);
then I create a pointer to that function:
int(*fp)(int,int); //I think this is the syntax...
the big question is that:
since this pointer points to data in memory, can I copy these data (the actual function code in memory) and copy it to a new location in memory?
I want to have to copies of the function in memory, and use them both.
if I can, how can I deteremine the length(in bytes) of that function? what are the explicit steps do I need to do?????????
Thanx all,
Mohammad Gdeisat
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Mohammad A Gdeisat wrote: can I copy these data (the actual function code in memory) and copy it to a new location in memory?
no. for one thing, the OS distinguishes between code and data, and vice versa. it takes some serious trickery to execute the stuff your app thinks is data.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Yesterday, when I was playing with Visual C++, I wrote this piece of code:
<br />
#include "iostream.h"<br />
#include "memory.h"<br />
int add(int a, int b)<br />
{<br />
return a+b;<br />
}<br />
<br />
void main()<br />
{<br />
typedef int (*func)(int,int);<br />
func fp;<br />
fp=add;<br />
<br />
unsigned char *buffer=new unsigned char[100];<br />
memcpy(buffer,fp,97);<br />
<br />
func fp2;<br />
fp2=(func)buffer;<br />
<br />
<br />
cout<<fp2(5,6)<<endl;<br />
<br />
cout<<"Function data: \n";<br />
<br />
for (int a=0;a<97/4+1;a++)<br />
{<br />
cout<<hex<<((int*)buffer)[a]<<endl;<br />
}<br />
delete []buffer;<br />
}
I figured out the size of the "function instructions" by trial and error, it was 97 bytes.
After copying function data to a new location in memory and creating a pointer to function that points to the copied function in memory, it just executed normally and smoothly. I was amazed, really!!!
But till now, I have the problem of determining the size of the function data, and everythink will work fine for me....
Can you help me in this??? or anyone else.
Thank you all.....
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Hi,
I created a dialog with a combo box.
I entered a few items ("A;B;C;D") to
the combox box's property->data field.
I know I need to call SetCurSel ( ) function to
sets the combo box's current selection by
a data index. Otherwise, the combo box appers
empty until I drop the list down.
I also read something about fixing the
problem in OnInitDialog ( ).
But I could not find out how they come together.
I think my question is where is "OnInitDialog".
Should I derive a new class from that combo box?
If that is the case, how my dialog display the
same combo box again?
Any suggestions would be appreciated?
Thanks,
Kevin
|
|
|
|
|
OnInitDialog is called by the framework before the dialog is displayed. It's an ideal place to do the sort of thing you want to do (fill combo boxes, set text in text boxes etc). It's a member function of CDialog, so (assuming you're using MFC), you'll need to override this function and put your code in there.
Note that although you are ultimately handling a WM_INITDIALOG message, in this case you don't need an entry in the message map, just an override of the base class function.
|
|
|
|
|
Hi-
go to class wizard and select the dialog box class on which your combo box is in, then from create an event handler(also from class wizard) for the WM_INITDIALOG message or the OnInitDialog() function, place your code to initialize (select the item you want in a combo box), the code in this function will be executed when your dialog box is initialized, and before it is visible on the screen.
Regrds,
Mohammad Gdeisat
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Great, it works.
One more question.
I have about 15 data (a;b;c;d;e;...) with my combo box.
When I clicked the combo box, it only showed one entry
at a time when I hit the up or down arrow.
How can I show multiple rows to be selected?
Thanks,
Kevin
|
|
|
|
|
kevincwong wrote: How can I show multiple rows
If you want the combo box to display more than on item when clicked, try this
In design mode,
Right click on the drop down box,
Use the selection box to resize the height.
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
I got it. It works.
Thank you so much!
Kevin
|
|
|
|