|
|
http://www.codeproject.com/cpp/cinifile.asp[^]
this link doesn't work.
and can i get an example code how to use CRegKey class for storing and retriving data.
I have around 11 feilds and i want to save them all.
thanks.
|
|
|
|
|
karmendra_js wrote:
http://www.codeproject.com/cpp/cinifile.asp
just try http://www.codeproject.com/cpp/cinifile.asp
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
karmendra_js wrote:
http://www.codeproject.com/cpp/cinifile.asp
this link doesn't work.
Did you not notice the extra stuff in the URL? Try it again but remove the extraneous characters.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
You can consider using the Registry to save your configuration data. Proceed as under (with MFC):
1. Use functions such as SetRegistryKey, WriteProfileString (for a string), WriteProfileInt (for int), GetProfileString, GetProfileInt, etc., of the application class for setting and accessing values from the Registry.
2. You can consider the Constructor or InitDialog functions wherein the stored values can be retrieved from Registry and displayed in the Configuration dialogbox.
3. Use OnOK (or whatever other button-event-handlers) to save the changed configuation data to registry.
4. Use these stored values appropriately in the code to change your program response. For example, use PreCreateWindow function of the mainframe class to change the position or size of main window using stored configuration data.
Regards,
Ashok Dhamija
_____________________________
Padam Technologies
|
|
|
|
|
Hi,
honestly I don't like Bill's registry very much...
If I need to store any configuration data this is my preferred way.
Regards
Achikm Klein
We can do no great things, only small things with great love. - Mother Theresa
|
|
|
|
|
Achim Klein wrote:
honestly I don't like Bill's registry very much...
Yeap Nice, But still you using Bill's Window for storing the data ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I have a problem with conversion, when i ran the code below, it gives me the error :
Error : ERROR_INVALID_PARAMETER (refer to trace code below).. Whats wrong with my code?
By the way Im using Embedded Visual 3, where the default setting of my Project is Unicode...
I have my own CSoString which is the same with CString but in plain C format ANSI and have some additional features in it. I want to convert first from unicode to ansi so that the converted ansi will be passed to CSoString like for ex.
CSoString mystring;
mystring.Copy(char* here); // where the char* is the converted Unicode to ANSI.
but before i copy it, i have to fix the problem with conversion....
Pls. see code below..
Thanks and More pOwer.
------------------------------------------- Code ----------------------------------------
CString m_wordSearchText; // this variable is a cstring of edit box.
LPSTR hold=0;
LPSTR hold2=0;
int len=WideCharToMultiByte(CP_ACP,0,(LPCWSTR)m_wordSearchText,-1,hold,0,NULL,NULL);
if (len==0)
{
DWORD lerror=GetLastError();
switch(lerror)
{
case ERROR_INSUFFICIENT_BUFFER :
{
TRACE(_T("ErrorLen : ERROR_INSUFFICIENT_BUFFER\n")); break;
}
case ERROR_INVALID_FLAGS :
{
TRACE(_T("ErrorLen : ERROR_INVALID_FLAGS\n")); break;
}
case ERROR_INVALID_PARAMETER :
{
TRACE(_T("ErrorLen : ERROR_INVALID_PARAMETER\n")); break;
}
}
}
else
{
WideCharToMultiByte(CP_ACP,0,(LPCWSTR)m_wordSearchText,len,hold,len,NULL,NULL);
DWORD lerror=GetLastError();
switch(lerror)
{
case ERROR_INSUFFICIENT_BUFFER :
{
TRACE(_T("Error : ERROR_INSUFFICIENT_BUFFER\n"));
break;
}
case ERROR_INVALID_FLAGS :
{
TRACE(_T("Error : ERROR_INVALID_FLAGS\n"));
break;
}
case ERROR_INVALID_PARAMETER :
{
TRACE(_T("Error : ERROR_INVALID_PARAMETER\n"));
break;
}
}
}
TRACE2("UniCodeWord=%s ConvertedWord=%s\n",m_wordSearchText,hold);
|
|
|
|
|
You didn't initialize the Ansi string, it points to NULL.
Just prior to the second WideChar call, insert the code:
<br />
hold = new char [len + 1];<br />
WideCharToMultiByte(CP_ACP,0,(LPCWSTR)m_wordSearchText,len,hold,len,NULL,NULL);<br />
hold[len] = '\0';<br />
<br />
...<br />
<br />
delete [] hold;<br />
<br />
I usually use a CStringA object instead of allocating with new, not sure if it's part of Embedded Visual 3.
He is smart. He will make our Windows go.
-- modified at 7:11 Thursday 15th September, 2005
|
|
|
|
|
Hi,
Thanks for the code. It works.
More power to you..
|
|
|
|
|
In My compiler option i gave /gx option but still i get warning
warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX
No error
But
when compiled in release MinDependency
I am getting Compiler error
error LNK2005: __fltused already defined in StdAfx.obj
plz help its urgent
Sagar
Love Is photogenic,It require a dark to develope
|
|
|
|
|
hi
i want to know how Gprs works. it work through the ports or any device is required. what i want to do is transfer file from the computer to PDA rhrough the GPRS any body can guide me what is requirement of gprs.
ddd
|
|
|
|
|
tasleem143 wrote:
rhrough the GPRS any body can guide me what is requirement of gprs.
This link might Help:-
GPRS INTRODUCTION[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi! i'm a computer science student and have been given an assignment to implement Huffman Encoding and Decoding.
I understand the principles in Huffman Encoding and decoding but i don't know how to implement it. could anyone help me to write the source code with explanations if possible
thx
Just email me
|
|
|
|
|
|
I want to simulate an input and post into a web page and than download the web page that is opened after the correct input! The web page exists of an user input form with userid and password, after input the correct data and pressing the submit button another web page will be opened.
I have tried to download the web page with the following code (I am using the CAmHttpSocket class at http://www.codeproject.com/internet/amhttputils.asp):
int _tmain(int argc, _TCHAR* argv[])
{
CAmHttpSocket http;
char* p = "userid=xxx&pwd=xxx";
char* s = http.GetPage(
_T("https://orawww.uibk.ac.at/public_prod/owa/pk205.frame_lv_termine_lzk?termin_id_in=3678"),
true, p, strlen(p));
int i = http.GetPageStatusCode();
printf("%s\n", s);
printf("%d\n", i);
return 0;
}
My problem is that I don't know how to simulate the input and pressing the submit button!
How can I pass the userid and the possword?
Regards,
Daniel.
--
FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE.
-- modified at 4:46 Thursday 15th September, 2005
|
|
|
|
|
I have used PreTranslate message to capture the renaming of Tree Nodes.
I am capturing the VK_RETURN key to complete the renaming of tree nodes.
But the tree control can also complete the rename operation by clicking the mouse anywhere on the tree control after typing the new string for the folder.
I dont want the rename to take place by mouse click. I know how to revert the old string of the tree node .But I dont know what event completed the rename operation .Like if i can differentiate the end of rename operation by mouse or by keyboard i can block the mouse rename operation.
I tried to do the following filter .
void CTreeCtrlBar::OnTvnEndlabeleditTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
if (pNMTreeView->action == TVC_BYKEYBOARD)
AfxMessageBox("End by ENTER Key");
else if (pNMTreeView->action == TVC_BYMOUSE)
AfxMessageBox("End by mouse click");
**************************************************************************
But always the condition pNMTreeView->action == TVC_BYMOUSE gets satisfied
even when I pressed ENTER key to complete the rename operation.
Any suggestions please.
laiju
|
|
|
|
|
I am beginer for VC and MFC. I want to develop an Encyclopedia type Application to combine huge amount of Literature of URDU. Encarta 2005 attracted me due to its intractiivity. What are the technologies should I foucs to develop encarta like applicaiton. What is the possible structure of Encarta. How files and articles are stored. How Searches are made.
Shoaib Nawaz
|
|
|
|
|
Its a big project try to gain some grip on VC++
and then give shape to the project that what i
can tell u .;)
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
hi~~
now i am working on a project encounter a problem ,i want print the right of screen
but everytimes print start lift of screen how can i print start from right of screen??????????????????????????????????????
nothing
|
|
|
|
|
Hello,
I am new to VC++ and this forum too. i want to know how can I perform following task in VC++ 6 using MFC.
I am writing host application and device drivers for a USB HID Device. I have a situation here, Whenever i call writreport function to write data to the USB HID device it has to Acknowledge. But buy any chance if device do not send back a response, the host software hangs( doesn't respond to user input).
I thought of a solution for this, I will call the write report function in a thread and let thread wait for the ack from device. mean while the host application will wait for thread to complete for a specified time and if thread does not respond with in time then it(host) should shutdown the thread.
Now I need your help here, the problem is I donot know how to implement it.( I just konw how to create a thread but have no idea how to wait for sometime and if no response exit the thread).
thanks a lot for your time to read this.
and thnaks for your help if you do so
|
|
|
|
|
WaitForSingleObject() should do the trick. The first parameter will be the handle of your thread, and the second parameter will be the milliseconds to wait. WaitForSingleObject will return WAIT_OBJECT_0 if the thread terminates, or WAIT_TIMEOUT if the thread does not terminate in the specified time.
"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!
|
|
|
|
|
Thanks, thanks a lot for that info. I implemented it as follows.
///////////////////////////////////////////////////////////
DWORD WINAPI WriteMdsDataPseudoThread( IN LPVOID vThreadParm )
{ //Calling the member function in seperate thread.
CDevice* pThreadParam = ( CDevice* ) vThreadParm;
pThreadParam->write_mds_data_thread();
return 1;
}
unsigned short CDevice::write_mds_data(unsigned char *message )
{
msg=message;
ExecuteWriteThread();//call to start the thread
return 1;
}
int CDevice::ExecuteWriteThread()
{
HANDLE hThread = NULL;
DWORD dwThreadID = 0;
int nTimeout = 1000;
try
{
//Creating the thread
hThread = CreateThread( NULL, // Pointer to thread security attributes
0, // Initial thread stack size, in bytes
WriteMdsDataPseudoThread,
this, // The argument for the new thread is a pointer to CDevice object
0, // Creation flags
&dwThreadID ); // Pointer to returned thread identifier
}
catch( CException* /* pException */ )
{
AfxMessageBox("Write Error. Please retry");
return false;
}
WaitForSingleObject(hThread, nTimeout);
DWORD dwWaitReturn;
GetExitCodeThread(hThread, &dwWaitReturn);
if(STILL_ACTIVE == dwWaitReturn)
CloseHandle(hThread);
return 1;
}
///////////////////////////////////////////////////////////
but i am not sure, that the thread is terminated releasing all the resources.
And my host application still hangs.
can you help.
Thanks again.
Who is your hero? Only one who helps you, who cares about everyone problems.............Do you wanna be HERO?
|
|
|
|
|
Hello...
First, You use MFC then you should you use the Threading function from MFC like AfxBeginThread because some MFC internals need to prepared for Threading...
When you use the pure API calls in the MFC it can produce unexpected situations and also Memory Leaks...
Second, when you use the pure API then always closing the Thread Handle...
Third, Use the Sleep function in your worker thread to enforce a context switch this can improve the performance of your app...
Fourth... I believe you should read some more articels about threading before you continue your work...
You can find the most important facts about threading here (especially for MFC) : http://www.codeproject.com/threads/usingworkerthreads.asp[^]
Best regards...
|
|
|
|
|
If this is an MFC application, why are you using CreateThread() ?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|