|
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
|
|
|
|
|
kevincwong wrote: Thank you so much!
No problem...
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
Hello,
I am using a list control in my MFC Application.
I need to add items to the list control. So I use CListCtrl::InsertItem member method. And my app compile without any problem.
But at runtime, after adding 17 items to the control, the programm ends with a MessageBox displaying "Invalid Hook Descriptor". I've tried several times and it always ends after the 17th item added.
I don't use any hook in my app.I don't even know what a hook is.
Can somebody helps me?
Thanks
|
|
|
|
|
i think your code had some bugs, so you must attach your code.
c++
|
|
|
|
|
I Creat an SDI Application with CTreeView as a main view, How can i access and manpulate the CTreeView from a CDialog class in the same application ?
M. Gamal
|
|
|
|
|
One solution :
- Add a pointer to your main view in the App class
- Then in the CTreeView constructor you initialize the pointer with the local this pointer. You can access the pointer member variable using "theApp" object. It is the current instance of your application and it is availabe since you include your app header (for instance "myApp.h")
-You can access that pointer member everywhere provided that you include the header("myApp.h")
|
|
|
|
|
may be you need to pass the handle of the tree view window to the dialog box you create, either by sending a message or a member function call. In your dialog use the handle of the tree view to get a pointer to the tree view, and access it freely
good luck,
Mohammad Gdeisat
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
I would like to align some static variables (floats) to 16 byte boundary's so I can use SSE instructions to speed up calculations. In microsoft visual C++ this is very simple:
__declspec(align(16)) float A[65536];
&A[0]=0x???????0
But for my current project I have to use Borland C++ compiler. The Borland compiler does not support the align keyword. It is very easy to align dynamic variables to 16 byte boundary's using the function VirtualAlloc:
lpAddress=VirtualAlloc(NULL,65536*4,MEM_COMMIT,PAGE_READWRITE);
lpAddress=0x????0000
But if it is possible I would like to use static variables. I have tryed the following:
typedef struct
{
CHAR cPadding[16];
}PADDING;
#pragma pack(16)
PADDING padding;
FLOAT A[65536];
#pragma pack()
#pragma pack(16)
LONG DOUBLE padding1;
LONG padding2;
SHORT padding3;
FLOAT A[65536];
#pragma pack()
but this does not work. Does anyone have experience with this?? Thank You in advance
|
|
|
|
|
Is it possible to turn off and on resize for individual columns?
|
|
|
|
|
I'm writing a project using DirectX 8 SDK in VS 6.
I'm having a problem with following:
Compiler doesn't understand new data types that I need to use.
IDirectSound m_pSound; // OK
IDirectSound8 m_pSound8; //Use of undefined struct IDirectSound8
In dsound.h IDirectSound8 for example defined as new data type only if DIRECTSOUND_VERSION constant is more than 0x8000.
I tryed to define it as 0x8000 in my stdafx.h, but it didn't help.
How do I force my copmiler to understand new data types?
|
|
|
|
|
First of all, if dsound.h has something like this
#if DIRECTSOUND_VERSION > 0x8000
class IDirectSound8 {
... then you will need to #define DIRECTSOUND_VERSION 0x8001 at least in order for the #if test to be satisfied.
Also, you may need to #define more than one value to enable the definition of IDirectSound8 . Check dsound.h to make sure you've got all of the requirements.
Software Zen: delete this;
|
|
|
|
|
I defined DIRECTSOUND_VERSION as 0x0801 almost everywhere it is possible (having redifinitions though).
Now I declare a variable:
IDirectSoundCapture8* m_buffer;
I get an error: 'missing storage-class or type specifiers'
If I change the type of m_buffer to IDirectSoundCapture everything compiles well.
I also looked into dsound.h and didn't find any more defines I need to use
|
|
|
|
|
I resolved the error!
It turned up, that VC++ has it' own DirectX.
The solution was to move in Tools->Options-Directories directories containg the DirectX 8 SDK to the most top, so compiler include them first and only then standard VC files
let's try everythin'!
|
|
|
|
|
Hello,
I am having a problem with a function. I am trying to increment a variable (odometer) using the speed and distance traveled.
Below is what I have. Any suggestions are appreciated.
Thanks,
Eric
<br />
void drive( int, int );
<br />
<br />
<br />
<br />
void Car::drive( int spd, int minutes )
{<br />
int remainderMinutes = 0;<br />
int hours;<br />
int distance;<br />
<br />
system( "CLS" );<br />
<br />
while( minutes > 60 )<br />
{<br />
remainderMinutes += minutes % 60 * oneDividedBySixty;<br />
minutes += remainderMinutes;<br />
}<br />
<br />
hours = minutes * oneDividedBySixty;<br />
<br />
distance = spd * minutes;<br />
<br />
cout << "\n\n The distance is " << distance << ".";<br />
cout << "\n\n The speed is " << speed << ".";<br />
cout << "\n\n The time is " << minutes << " minutes.";<br />
}<br />
<br />
<br />
<br />
int main()<br />
{<br />
Car c;<br />
<br />
char choice;<br />
do<br />
{<br />
cout << "\n\n\n Please make a selection from the menu.\n\n";<br />
cout << "\n Press 'D' to display the car attributes.\n";<br />
cout << "\n Press 'R' to reset the car attributes.\n";<br />
cout << "\n Press 'X' to exit the program.\n";<br />
<br />
cin >> choice;<br />
choice = toupper( choice );<br />
<br />
switch( toupper( choice ) )<br />
{<br />
case 'D': c.printCar();<br />
break;<br />
<br />
case 'R': c.reset();<br />
break;<br />
<br />
case 'X': break;<br />
<br />
default: cout << "\n Unknown choice entered.\n"<br />
<< " Enter a new choice.\n\n";<br />
break;<br />
}<br />
<br />
} while ( choice != 'X' );<br />
<br />
<br />
c.reset();<br />
<br />
c.printCar();<br />
<br />
<br />
<br />
c.drive( c.getSpeed(), c.getMinutes() );<br />
<br />
<br />
<br />
cout << "\n\n\n ";<br />
<br />
return 0;<br />
<br />
}<br />
|
|
|
|
|
You should start by describing what your problem is.
SkyWalker
|
|
|
|
|
My problem is that the remainderMinutes equation is not working correctly.
Thank you,
Eric
|
|
|
|