|
I need a way to launch an external application (like notepad.exe) from a click within the page displayed in the CHTMLVIEW of an MFC application. I accomplished this with wscript.shell.run in javascript but I get an annoying prompt every time with a yes or no for whether i want to allow the active X content to run. ALL the internet explorer script and active X stuff has been set to "Enable" and i still get this. Is there some better way to launch an application based on a link in the webpage that won't prompt the user each time?
|
|
|
|
|
Well I know that you can launch an exe with Internet Explorer by assigning a protocol to the exe
Insert the following into the registry:
[HKEY_CLASSES_ROOT\notepad]
@="URL:notepad Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\notepad\shell]
[HKEY_CLASSES_ROOT\notepad\shell\open]
[HKEY_CLASSES_ROOT\notepad\shell\open\command]
@="\"c:\\notepad.exe\" \"%1\""
Your link will then need to be notepad:parameters
where parameters are the parameters you wish to pass.
Change notepad above to whatever name you wish for your protocol.
|
|
|
|
|
i suggest you take a look at many articles here in CP by people who mamanged to intercept javascrip or url click inside HTML doc displayed through CHTMLView.
Thus you will be able to code whatsoever application or action you may want to execute via the C++ code.
Good luck.
Our Philosophy, Mohammed Baqir Al Sadr
|
|
|
|
|
I have the following scenario :
there is a certain function declared as :
void Function1(int iArgument)
{
//Code Block CB1
}
Suppose that whenever in my source code I have multiple calls to that function :
int main()
{
int i,j,k;
Function1(i);
Function1(j);
Function1(k);
}
Now what I need to do is to be able to "grab the name of" the passed parameter variable, and use it to customize the behaviour of the function Function1.
For example would need something like :
void Function1(int iArgument)
{
CString argumentName= ??I do'nt knwo here.
//Then :
AfxMessageBox(argumentName);
}
Such that the result has to be for the main program as :
i
j
k
displayed each in consecutive messageboxes.
I tried with my head, but unsuccefully. I do'nt know, is it difficult, is it too obvious.
Can it be solved by simple macro ?
Please help me.
I need this becuase I want to develop a persistance framework for C++ in which objects are easily made persistant through easy function without the need to oblige the user to explicitly precise extra information for each argument to be serialized so to serve its distinction from other argument, and rather use automatic collection of the the source code names chosen by the developer for the arguments or variables.
Thank you in advance.And I can't live without you.
Our Philosophy, Mohammed Baqir Al Sadr
|
|
|
|
|
No hope.
You must give your function an additional argument, for instance:
void Function1(int iArgument, LPCTSTR sArgName );
{
CString argumentName = sArgName;
}
Then you can hide it in function call using a macro, such as
#define FUNCTION1(s) Function1(s, #s)
FUNCTION1(i);
FUNCTION1(J);
But that's only a palliative (and it's a bit weird).
Why don't you have a look at MFC serialization, instead?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thank you M. Pallini,
indeed I have to thank you for that very useful trick of the "#"symbol.
Indeed it is for me a the way to automatically collect and exploit the naming information
that the developer used for his vraiables.
MFC serialisation is not sufficient for me. becuase I am seeking to something very general that
is basis for storing my C++ objects in database, their reconstruction, as well as their
easy transmittion via network.
but I am facing pbm now :
I want to implement << operator for certain CPacketBase class upon primitive type like int,etc :
CPacketBase& CPacketBase::operator<<( int iArgument )
{
putArgumentAtCurrentXMLLevel(argumentName,iArgument);
return *this;
}
The problem is now << does not accept two argument such I can supply the name of the argument to the right of the value argument itself.
and the argumentName value is indeed the key for value, the key upon which the reading process can explore the data inside the stream, where it should go etc..
Anyway i do'nt want to make you waste your time. I appreciate your help.
plesae if u allow me to comment on your top sentence :
"If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile."
then I would say it is not wise to suggest to be in position to question God's choices, or in position to be able to give
consultance or advice to God Almighty. becuase since God the Almighty is the all wise, the all creator, then
the maximu wisiness I or any human can achive is to admit that the creature can not be wiser than its creator, the one who
created its head, way of thinking, algorithm and memory,etc.
i hope you accept my comment.
Our Philosophy, Mohammed Baqir Al Sadr
|
|
|
|
|
You may go on with the weird tricks and build and object on the fly, for instance (only to give you the idea):
#define WRAP(i) Wrap(i, #i)
struct Wrap
{
int _i;
string _s;
Wrap(int i, string s):_i(i), _s(s){}
};
ostream & operator <<(ostream & o, Wrap w)
{
o << w._s << "(" << w._i << ")";
return o;
}
void main()
{
int i;
i=5;
cout << WRAP(i) << endl;
}
hINTModuleState wrote: plesae if u allow me to comment on your top sentence :
"If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile."
then I would say it is not wise to suggest to be in position to question God's choices, or in position to be able to give
consultance or advice to God Almighty. becuase since God the Almighty is the all wise, the all creator, then
the maximu wisiness I or any human can achive is to admit that the creature can not be wiser than its creator, the one who
created its head, way of thinking, algorithm and memory,etc.
i hope you accept my comment.
I accept your comment, of course.
BTW I hope you enjoyed the irony of Alfonso and, after all, that went on my arrogant assumptions...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thank you again Mr Pallini ! This solvs the problem with primitive types.
Of course I will do it : the people of JAVA and C sharp and Scala and the others have permitted to theirself to accept that the simple instruction be implemented and behinded by throusands of translation instructions.
If such thing as the onthe fly create of a struct wrapper of a primitive type only would have a minor effect at the parameters collection before the actual serialization process, and that in the reverse it will help users not need to precise the name of the primitive type vriable, next to the value of it, then it is OK, it is acceptable and I permit myself to do it !
Thank you again.
I have to laugh at myself indeed at recognizing that that sentence on which I commented was a joke !
Our Philosophy, Mohammed Baqir Al Sadr
|
|
|
|
|
If you create objects with name you have the possibility.
MyOb
{
Cstring name;
int values;
};
Func( MyOb b );
Greetings from Germany
|
|
|
|
|
yes for objects I have no problems. I alreeady created a base class with base key data member that will be queried upon inside Func howsoever the b object is (of course it sould be a derivative of my base).
Thnk you for your intervention.
Our Philosophy, Mohammed Baqir Al Sadr
|
|
|
|
|
So i only have pbm with primitive data types like int, CStrng, etc for which I need to supply the actual vriable name.
Our Philosophy, Mohammed Baqir Al Sadr
|
|
|
|
|
hINTModuleState wrote: Now what I need to do is to be able to "grab the name of" the passed parameter variable, and use it to customize the behaviour of the function Function1.
That is bad design. Take one mental step back and think what you want to *Do*.
You need to transport information about a WHAT (your variable value) and a HOW into your function. You can either introduce another parameter (as already posted).
Alternatively, and more "The C++ way" would be to use different parameter types and overloading.
class Strategy
{
public:
Strategy( int Value}
: m_value( Value)
{}
int GetValue(){ return value;}
private:
int m_value;
}
class StrategyA : public Strategy
{
StrategyA( int Value) : Strategy( Value)
{}
}
class StrategyB : public Strategy
{
StrategyB( int Value) : Strategy( Value)
{}
}class StrategyC : public Strategy
{
StrategyC( int Value) : Strategy( Value)
{}
}void Function1(StrategyA iArgument)
{
}
void Function1(StrategyB iArgument)
{
}
void Function1(StrategyC iArgument)
{
}
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
yes yes I am totally with you.
but for primitive types I needed that sort of trick which M Pillini game me so to automatically grad the variablke name and not oblige the developer to explicitly put a key name next to the var value.
it is also useful since he may forget to supply the wrong key name in the reverse process (reading process as opposed to storing, or receiving as opposed to sending the primitive var).
As for object, yes indeed I have the things that you explianed. More thnat that and since I may have differente types of objects serialized in same stream to be sent or saved to disk, which havce same key, then I need to add a type data member to the base class.
class CSerializeObjBase
{
public:
CSerializeObjBase(CString key,CString objType)
{
this->key=key;
this->objType=objType;
}
CSerializeObjBase(int key,CString objType)
{
this->key.Format(_T("%d"),key);
this->objType=objType;
}
~CSerializeObjBase(void){};
private:
CString key;
CString objType;
public:
void setObjKey(CString key){
this->key=key;
};
CString getObjKey(){
return key;
};
CString getObjType(){
return objType;
}
virtual bool serializeObject(CPacketBase* pStore){
return false;
};
};
Thk you for your intervention; and forgive the bad words, bcuase i am arab and consume time to formulate right sentences in english ans i am hurry now but i recognize the necessity of replying to you and thanking you.
So Thank you for your help.
Our Philosophy, Mohammed Baqir Al Sadr
|
|
|
|
|
i want to add for you all before i go to take the bus, that indeed i could have given up the necessity of exploiting of vraiable naming information, and rather exploited the simple order by which the variables or objects are put in the stream, in the serialisation process wether while writing to file or db or sending to network.
becuase in the reverse process the developer will have to take care of th e exact reverse order of fetching stream elkemnst onto vraiables and memebers of the object or objects obnside the object.
I am in a bad position. the java and C# people have an interprested lalgage so it is possible for them to query an unknow object type and ask it for its type and even query oits memùbers and even functions.
Thus it is easy for them to consstruct automatic tools for sending objects and i do'nt know.
for me i have many personal unmanaged C++ programs and i want besides to take the strategic decision of staying with unmanaged code. but of course i can not accept to be bypassed by the java and the C sharp people so i must do something even though C++ is not interpreted.
Thank you.
Our Philosophy, Mohammed Baqir Al Sadr
|
|
|
|
|
Hi,
I have an MFC app for which icon is displayed normally in all conditions except this -
- When I open 2 instances of the app and Windows XP groups them into 1 single entity in taskbar, the icon displayed is something other than my app original icon.
Any ideas regarding this ? (I'm already doing a SetIcon btw at my side)
Regards
Cage
|
|
|
|
|
Have you changed all resolutions of your icon? In one .ico file can be several sizes (16x16, 32x32, 48x48).
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Okay. So, you mean to say I should have 3 sizes images embedded into the ico file ?
The way I created the icon was to use create a 32 * 32 size icon.
Btw - how can we see for an ico file - how many sizes does it support ?
Thanks for the help,
Cage
|
|
|
|
|
cagespear wrote: Btw - how can we see for an ico file - how many sizes does it support ?
I use Visual Studio's built-in icon editor.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Ok. so I just added 16 * 16 as well as 48 * 48 image sizes to my icon. I can see all 3 sizes - 16, 32 and 48 in my visual studio icon editor.
But my problem still continues ...
As I told you earlier - I can see the icon fine in the titlebar, in the icon which shows up when you do an alt+tab but I see the default icon(hand with videocamera) rather than my app icon in taskbar properly when I have more than 1 instances open for my app and windows xp has "grouped" them into 1 with its taskbar setting.
1 part which I missed earlier was even in the xplorer view, the icon for my app is that default one instead of original app icon.
Thanks for your time,
Regards
Amit
|
|
|
|
|
The app icon is sometimes tricky. Best is to give it the lowest icon ID in the resource.h.
And as some rightly mentioned support all possible sizes and bit depths in the icon.
Greetings from Germany
|
|
|
|
|
KarstenK wrote: The app icon is sometimes tricky. Best is to give it the lowest icon ID in the resource.h
I second that. I had a similar problem which was solved by doing this
Graham
Librarians rule, Ook!
|
|
|
|
|
Hi all,
please tell me how can i convert CString to float or vice Versa.
i m using this,
float fvar;
CString foo;
foo = "123.45";
fvar= atof(foo);
but this not working.
Please tell me.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
ThatsMe. wrote: but this not working.
any error message ?
|
|
|
|
|
No there is no error message.
but after calculation the final resul is Zero, that is wrong.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
try
fvar= atof((LPCSTR)foo);
Graham
Librarians rule, Ook!
|
|
|
|