|
Thanks, right after the post I setup a function to do just that.
The MDI app is a tabbed chat client, when a new person msg's the user I didn't want the new tab/doc to pop-up in front especially if the user was in the middle of typing to someone else....
Anyway thanks for your help,
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
char lpBuffer[256];
GetPrivateProfileString()
"FYP", // LPCTSTR lpAppName
"MyKey1", // LPCTSTR lpKeyName
"0", // LPCTSTR lpDefault - in case file does not exist this is default
lpBuffer, // LPCTSTR lpReturnedString
256, // DWORD nSize
"File.ini" // LPCTSTR lpFileName
);
WritePrivateProfileString()
"FYP", // LPCTSTR lpAppName
"MyKey1", // LPCTSTR lpKeyName
"0", // LPCTSTR lpString - whatever you want to save
"File.ini" // LPCTSTR lpFileName
);
Can someone explain to me how to go about using this privateprofilestring
|
|
|
|
|
You have to specify the full path to the file.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
char lpBuffer[256];
GetPrivateProfileString()
"c:\Desktop\FYP", // LPCTSTR lpAppName
"MyKey1", // LPCTSTR lpKeyName
"0", // LPCTSTR lpDefault - in case file does not exist this is default
lpBuffer, // LPCTSTR lpReturnedString
256, // DWORD nSize
"File.ini" // LPCTSTR lpFileName
);
WritePrivateProfileString()
"FYP", // LPCTSTR lpAppName
"MyKey1", // LPCTSTR lpKeyName
"0", // LPCTSTR lpString - whatever you want to save
"File.ini" // LPCTSTR lpFileName
);
You mean like this?
|
|
|
|
|
No, the last parameter must contain a full path to your file.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
ic..u mean FYP.doc?
Then do i need to declare variable in the GetPrivateProfileString()function?
Then what do i key in for "MyKey1"?
GetPrivateProfileString()
"c:\Desktop\FYP", // LPCTSTR lpAppName
"MyKey1", // LPCTSTR lpKeyName
"0", // LPCTSTR lpDefault - in case file does not exist this is default
lpBuffer, // LPCTSTR lpReturnedString
256, // DWORD nSize
"File.ini" // LPCTSTR lpFileName
);
Thanks alot
|
|
|
|
|
I think he means File.ini should be c:\Desktop\FYP\File.ini or what ever your path is.
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
char* lpFullPath = "C:\\Program Files\\MyProgram\\File.ini";
GetPrivateProfileString("MYAPPNAME", "MyKey", "error", lpBuffer, 256, lpFullPath);
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
#include "stdafx.h"
char lpBuffer[256]
{
GetPrivateProfileString("MYAPPNAME", "MyKey1", "error", lpBuffer, 256, C:/Desktop/FYP.ini)
"MYAPPNAME", // LPCTSTR lpAppName
"MyKey", // LPCTSTR lpKeyName
"0", // LPCTSTR lpDefault - in case file does not exist this is default
lpBuffer, // LPCTSTR lpReturnedString
256, // DWORD nSize
"C:/Desktop/FYP.ini" // LPCTSTR lpFileName
WritePrivateProfileString(("MYAPPNAME", "MyKey1", "error", lpBuffer, 256, C:/Desktop/FYP.ini)
"MYAPPNAME", // LPCTSTR lpAppName
"MyKey1", // LPCTSTR lpKeyName
"0", // LPCTSTR lpString - whatever you want to save
"C:/Desktop/FYP.ini"// LPCTSTR lpFileName
}
return 0;
Is this programme correct now?
Do I leave MYAPPNAME as it is?
|
|
|
|
|
void MyFunction()
{
char lpBuffer[256];
GetPrivateProfileString("MYAPPNAME", "MyKey1", "error", lpBuffer, 256, C:/Desktop/FYP.ini);
WritePrivateProfileString(("MYAPPNAME", "MyKey1", "error", lpBuffer, 256, C:/Desktop/FYP.ini);
}
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
Hi,
I am getting an linker error like this. Please let me know the include files or the libraries needed and also how do I navigate through the visual studio to include them.
.......
Generating Code...
Compiling resources...
Linking...
nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
nafxcw.lib(filelist.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcw.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcw.lib(viewedit.obj) : error LNK2001: unresolved external symbol __mbctype
Thanks,
Prashant
|
|
|
|
|
Hi guys.
Maybe this is a silly question, but I'm trying to move a control when I press a button and is not working as desired.
I have a Single Document App with a CFormView where I call a Modal Dialog. In this Dialog I have an static control IDC_MYSTATIC
What I'm trying to do is to move 20 pixel on the right this STATIC when I press a button.
I'm a little confused with GetWindowRect(...) GetClientRect(...) and the STATIC is not redraw where I supose it had to be.
Could you please tell me the correct way to move my STATIC in my window?
Best Regards
Doc
|
|
|
|
|
Inside the dialog, you need to do a GetWindowRect() for the static control, convert the coordinates to client coordinates, add 20 to left and right then move the control:
CRect rect;<br />
m_staticControl.GetWindowRect(rect);<br />
ScreenToClient(rect);<br />
rect.left += 20;<br />
rect.right += 20;<br />
m_staticControl.MoveWindow(rect);
(You could replace the last line with the following:
m_staticControl.SetWindowPos(NULL, rect.left + 20, 0, 0, 0, SWP_NOCOPYBITS | SWP_NOREPOSITION | SWP_NOSENDCHANGING | SWP_NOSIZE |<br />
SWP_NOZORDER);
)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
anyone know whats the win32 command to write multiple lines of text to an edit box. I've created a project using the wizard and just dragged the edit box to the dialog.
Note: SetWindowText doesn't appear to work for a multiline edit box (i.e. to write many lines of text to this edit box)
Kind Regards
Kevin
|
|
|
|
|
In the properties of the edit box select multiline.. Once you do that you can use SetWindowText and seperate lines using \r\n so "Line One\r\nLine Two"
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
SetWindowText("A\r\nB\r\nC\r\n");
i.e.
A
B
C
This idea is fine if you want to write lines to the edit box just once.
However I've a scenario where I need to write one line of text in one function another in another function and so on. The idea suggested won't work.
Any other suggestions much appreciated
Kind Regards
Caoimh
|
|
|
|
|
You could use GetWindowText in each of your functions to get the text that is already in the edit box then append to it.. that way each function doesn't clear the exit box's test.
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Hi,
I'd like to trigger an event within my application at a specific time. Is there a better way other than installing a timer with SetTimer() and check the current time every 1 second?
Thanks in advance.
Have no fear of perfection - You will never reach it
|
|
|
|
|
Take a look at CreateWaitableTimer and SetWaitableTimer. Below is the example from MSDN. Create a Thread to monitor for your event and then use SetWaitableTimer. When the the timer is signalled you can do what you need. SetWaitableTimer can either be set for an absolute time or a relative time(as in the example). If you use absolute time pay attention to your time local time offset.
#include <windows.h>
#include <stdio.h>
int main()
{
HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime;
liDueTime.QuadPart=-100000000;
// Create a waitable timer.
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
if (!hTimer)
{
printf("CreateWaitableTimer failed (%d)\n", GetLastError());
return 1;
}
printf("Waiting for 10 seconds...\n");
// Set a timer to wait for 10 seconds.
if (!SetWaitableTimer(
hTimer, &liDueTime, 0, NULL, NULL, 0))
{
printf("SetWaitableTimer failed (%d)\n", GetLastError());
return 2;
}
// Wait for the timer.
if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0)
printf("WaitForSingleObject failed (%d)\n", GetLastError());
else printf("Timer was signaled.\n");
return 0;
}
|
|
|
|
|
Thanks for the pointer, I've found the relative articles in msdn, but I can't see how these functions can be used in an MFC Doc/View context.
In the other example in msdn, the completion routine used is a global function.
My application needs to set the trigger and go about doing other things. It cannot halt until the event is triggered.
It ought to be something very easy to do, but it seems very complicated to me.
Have no fear of perfection - You will never reach it
|
|
|
|
|
I am not very familiar with Doc/View. So hopefully you can apply the following as appropriate.
What I normally do is create a thread, often times in the class constructor, that passes a this pointer as the thread parameter. The thread then calls back to the function that does the waitable timer. When the waitable timer completes it can set your trigger.
A simple illustration...
class myclass
{
myclass();
long settrigger();
static DWORD WINAPI waitthread();
long waittimer();
};
myclass::myclass()
{
HANDLE hThread(NULL);
DWORD dwThreadID;
hThread = (HANDLE)_beginthreadex(NULL, 0,
waitthread,
(LPVOID)this, 0,
&dwThreadID);
}
DWORD WINAPI myclass::waitthread(LPVOID pParam)
{
myclass* ptr = static_cast<myclass*>(pParam);
return(ptr->waittimer());
}
long myclass::waittimer()
{
/* Do all your work with waitable timer. */
/* If everything is good! */
settrigger();
return 0;
}
long myclass::settrigger()
{
/* Set your trigger */
return 0;
}
|
|
|
|
|
I want to serialize my C++ object to a persistent storage. Must I use CArchive? Can you suggest where to look first for examples?
Thank you
|
|
|
|
|
Hello,
void CExample::Serialize( CArchive& ar )
{
CObject::Serialize( ar );
if( ar.IsStoring() )
ar << m_strName;
else
ar >> m_strName;
}
With Regards,
R.Selvam
|
|
|
|
|
|
I'm adding a DXF-Export feature to existing diagram-drawing code. We have several different types of drawing code that we would like to export to DXF.
In circumstances like this, is it customary to overload the windows GDI functions (eg instead of calling Rectangle() directly, I'd call ModRectangle() which would then export to DXF OR write to the DC via Rectangle()) Or would it be better to just create new parallel code specifically for the DXF export of this drawing code?
I can see positive and negative repercussions for both techniques...
|
|
|
|