|
Hello,
How to make IE Add-on for translating text?
During opening page I need to convert text to another language and show it in IE instead of original text.
Any idea, some example?
|
|
|
|
|
I'm just goofing off and I'm having an issue with my ifstream variable ifile when I attempt to close it. I sorta understand why it's not working but I don't know how to maintain my elegance and still accomplish my purpose. Here is a simplified portion of the code I have now:
<br />
<br />
string GetFilename(char []);<br />
ifstream& OpenFile(string);<br />
<br />
<br />
void main()<br />
{<br />
string input;<br />
ifstream ifile;<br />
<br />
input=GetFilename("manipulate:");<br />
ifile=OpenFile(input);<br />
if (ifile.fail()){<br />
cout<<"File does not exist!";}<br />
else{<br />
ifile.close();}<br />
}<br />
<br />
<br />
string GetFilename(char special[12])<br />
{<br />
static string input;<br />
<br />
cout<<"Please enter the name of the file you wish to "<<special<<endl;<br />
cin>>input;<br />
return input;<br />
}<br />
<br />
<br />
ifstream& OpenFile(string input)<br />
{<br />
static char filename[80];<br />
strcpy(filename, input.c_str());<br />
<br />
static ifstream ifile;<br />
ifile.open(filename);<br />
return ifile;<br />
}<br />
<br />
This program crashes when I try to close a file I opened that actually exists. I figure it has something to do with, am I closing the ifile is OpenFile or the one in main? A quick solution would be to create a global ifstream variable but how exactly does one effectively return an ifstream variable? The static declaration in OpenFile probably is causing havok too. Any help would be greatly appreciated.
P.S. I'll still be thinking on this for a while...
|
|
|
|
|
Give this a try:
string GetFilename( const char* );
ifstream OpenFile( const string& );
void main()
{
string input;
ifstream ifile;
input=GetFilename("manipulate:");
ifile=OpenFile(input);
if (ifile.fail()){
cout<<"File does not exist!";}
else{
ifile.close();}
}
string GetFilename( const char* special )
{
string input;
cout<<"Please enter the name of the file you wish to "<<special<<endl;
cin>>input;
return input;
}
ifstream OpenFile( const string& input )
{
ifstream ifile;
ifile.open( input.c_str() );
return ifile;
}
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Well you helped make the code become simpler by this code I overlooked:
<br />
ifile.open(input.c_str());<br />
Thank you. Also I didn't know const was used in parameter passing to notify the compiler that the value would be left unchanged. Thank you #2. I can see I still have much to learn.
However closing the file still fails. I shall continue to work on this conundrum. If anyone would like to see the revised version, do say so.
|
|
|
|
|
Well... I tried making ifile a global variable. Doesn't work. In fact it only works if the ifile.open is inside the same function that closes it (main). Strange. I probably learned why a few years ago when I was taking intermediate c++, but now I've no clue. Oh well. I'll just leave it in main, no harm done ^_^. Thanks again for your help.
|
|
|
|
|
My mistake and yours.
The destructor will close the file. Change the code to:
bool OpenFile( ifstream& ifile, const string& );
...
ifstream ifile;
if ( OpenFile( ifile, input) )
...
bool OpenFile( ifstream& ifile, const string& input )
{
ifile.open( input.c_str() );
return !ifile.fail();
}
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
My project uses a resource that includes an Active X object, as well as buttons, edit boxes, etc. At run time there are many Modeless Dialogs that a user can start up using this resource. Each modeless Window opens and all are the same size. How can I make each modeless Window resizeable? I am not sure how resizing takes place in a project. Can someone help me out?
Thanks.
Jerry
|
|
|
|
|
Use SetWindowPos when spawning all these modeless dialogs (you need one call for each dialog).
|
|
|
|
|
Thanks, I am going to try to find an example of how to use that feature.
Have a good day.
Jerry
|
|
|
|
|
Search CP for: "dialog resize"
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Dear friends,
I want to write a small utility that runs in background and monitors certain folder on the Disk. The application keeps log of all the events on that folder i.e if someone opens that folder or copy file to that folder e.t.c; the application keeps log of all these events.
How can i monitor events on certain folder..is it possible ??
Imtiaz
|
|
|
|
|
|
I can't think of any particular function off-hand, but there certainly is such a trick in 9x as well as in NT (Expolrer manages to monitor changes from 3rd party programs as well). I remember finding it once among the Shell functions listed in MSDN, just try searching there.
|
|
|
|
|
|
In a multi resolution icon file i.e. WinXP icons, how can one determine that the icon is really a multi resolution and then how can one extract a specific resolution to add in an Image list.
I have several icons, with various sizes and color depths, I would like to build different size Imagelists for a toolbar.
|
|
|
|
|
Image list does it automatically, I think. Just get that icon with all the resolutions it has and then add it to your image list. It will pick a necessary resolution (i.e. the one you set) and add a single-resolution version of that icon.
|
|
|
|
|
Hi!
I'm having a problem with printing a special char in an RichEdit box by code.
My App was compiled with UNICODE & _UNICODE and I set the RichEdit to the right font.
While the App is running I can enter the character (square root) into the RichEdit by pressing Alt + 8730, but when I try print it with code
WCHAR ch[2] = {L'\x221A',NULL};
m_ctrlInput.SetWindowText(ch);
there is just a 'v' appearing.
When I set the ch[0] to any ascii code (< 256) it works fine, but it won't do it with Unicode characters.
Any suggestions?
|
|
|
|
|
Iam trying to convert a time count which is in milliseconds to get Date and Time in VC++,but iam unable to get any function in vc++ that serves my purpose.Is there any function which converts a count to Date and Time.
|
|
|
|
|
I assume you want to include milliseconds in the time display; otherwise this does not make since.
void MyStartTimer()
{
time_t t1, t2;
t1 = t2 = time(NULL);
while( t1 == t2 )
t2 = time(NULL);
m_timeStart = t2;
}
BOOL MyGetDateTime(struct tm* ptm, unsigned* pMilliseconds)
{
time_t timeEnd = time(NULL);
time_t seconds = m_dwTimeCount / 1000L;
*pMilliseconds = m_dwTimeCount - (seconds * 1000L);
struct tm* ptmLocal = localtime(&timeEnd);
if( ptmLocal )
{
memcpy(ptm, ptmLocal, sizeof(struct tm));
return TRUE;
}
return FALSE;
}
Oh well, something like that should work. The actual formating is up to you.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I have just run This Code from MSDN ,and see What M$ compiler generted for me
CODE
#include <list>
#include <iostream>
using namespace std ;
typedef list<int> LISTINT;
void main()
{
int rgTest1[] = {5,6,7};
int rgTest2[] = {10,11,12};
LISTINT listInt;
LISTINT::iterator i;
listInt.insert (listInt.begin(), 2);
listInt.insert (listInt.begin(), 1);
listInt.insert (listInt.end(), 3);
for (i = listInt.begin(); i != listInt.end(); ++i)
cout << *i << " ";
cout << endl;
}
Warnings
--------------------Configuration: 1 - Win32 Debug
Compiling...
4.cpp
D:\Alok\Working\TestProject\TEst\4.cpp(24) : see reference to function template instantiation 'class
std::basic_ostream<char,struct std::char_traits<char> >
&__cdecl std::operator <<(class td::basic_ostream<char,
struct std::char_traits <char> > &,const char *)' being
compiled
c:\program files\microsoft visual studio\vc98\include\ostream(305) : warning C4018: '!=' :
signed/unsigned mismatch
D:\Alok\Working\TestProject\TEst\4.cpp(24) :
see reference to function template instantiation 'class
std::basic_ostream<char,struct std::char_traits<char> >
&__cdecl std::operator <<(class std::basic_ostream<char,
struct std::char_traits<char> > &,const char *)' being
compiled
c:\program files\microsoft visual studio\vc98
\include\xmemory(37) : warning C4100: '_P' : unreferenced
formal parameter
c:\program files\microsoft visual studio\vc98\include
\xmemory(68) : see reference to function template
instantiation 'void __cdecl std::_Destroy(int *)' being
compiled
c:\program files\microsoft visual studio\vc98\include\
xlocnum(430) : warning C4100: '_Lobj' : unreferenced formal
parameter
c:\program files\microsoft visual studio\vc98
\include\xlocnum(431): while compiling class-template
member function 'void__thiscall std::num_put<char,class
std::ostreambuf_iterator<char,struct std::char_traits<char>
> >::_Init(const class std::_Locinfo &)'
Linking...
1.exe - 0 error(s), 17 warning(s)
Could any body suggest me the way to solve that.
"I Think this Will Help"
Alok Gupta visit me at http://www.thisisalok.tk
br/> visit me at http://www.thisisalok.tk
|
|
|
|
|
|
Yeah sir,
Service Pack 5 hs been installed on my computer.
thanks
|
|
|
|
|
I want to access explorer toolbar.for example i want to hide the menu bar on the explorer that appears when i open drive C. Can anybody help me how to do that in visual C++ 6. The problem is that i can get handle to menu of any window that is active on desktop just by getting handle to window.but how to get handle to toolbar of active window because as far as i think the menu of explore is not just menubar as in dialog based application but it is menu bar over a toolbar.
|
|
|
|
|
On a dialog application I would like to capture keyboard input when I press a button and then stop when the button is pressed again.
I have included the WM_CHAR and WM_KEYDOWN messages on the dialog, but they are not activated.
I can type into an Edit box on just press keys when over the dialog, but breakpoint in
void CKeyBoard_CDNUDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) is never reached.
Is there something else I need to do in order to get the keyboard characters pressed.
|
|
|
|
|
You need to do it in PreTranslateMessage.
BOOL CMyDialog::PreTranslateMessage(MSG* pMsg) <br />
{<br />
if (pMsg->message == WM_KEYDOWN)<br />
{<br />
if (pMsg->wParam == some_key_code)<br />
{<br />
Do_SomeThing();<br />
}<br />
}<br />
<br />
return CDialog::PreTranslateMessage(pMsg);<br />
}
|
|
|
|