|
The
GetPrivateProfileXXX and
WritePrivateProfileXXX
functions do the job for you
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi, everyone:
Can someone provide a EZ way to change an individual text in a dialog? I knew that I can use CDC functions to realize that, but can I do this on a Static Control? To talk in detail, I wanna use SetWindowText() or SetDlgItemText( ) to change the text of a control containing some text string. And what should I do to change the reulting text? Or don't think about that, simply use CDC functions? Thanks!
|
|
|
|
|
Handle the WM_CTLCOLOR message.
In VS call the properties for the dialog, there you can set handlers for messages, in that list is a WM_CTLCOLOR message. Choose a function to handle this.
Write something like this in it:
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);<br />
CBrush *brush;<br />
brush = NULL;<br />
CWnd* pStaticWnd = (CWnd*)GetDlgItem(IDC_STATIC_STATUS);<br />
if(pWnd == pStaticWnd){<br />
pDC->SetTextColor(RGB(0, 0, 255));<br />
}
pStaticWnd = (CWnd*)GetDlgItem(IDC_STATIC_INFO_DOC);<br />
if(pWnd == pStaticWnd){<br />
if(lock_docstatus_text){<br />
pDC->SetTextColor(RGB(0, 100, 200));<br />
}
else{<br />
pDC->SetTextColor(RGB(0, 0, 255));<br />
}
}
pStaticWnd = (CWnd*)GetDlgItem(IDC_STATIC_INFO_SEND);<br />
if(pWnd == pStaticWnd){<br />
if(lock_sendstatus_text){<br />
pDC->SetTextColor(RGB(0, 100, 200));<br />
}
else{<br />
pDC->SetTextColor(RGB(0, 0, 255));<br />
}
}
return hbr;<br />
for more info check out msdn.
Hope this helps, good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
It didn't work....
But if the condition in if() changed to this form could work:
if( pWnd->GetDlgCtrlID() == IDC_STATIC_MY_STATIC )<br />
{<br />
pDC->SetTextColor(RGB(255, 0, 0));<br />
}
Anyway, thnks for your help.
|
|
|
|
|
ytod wrote:
To talk in detail, I wanna use SetWindowText() or SetDlgItemText( ) to change the text of a control containing some text string. And what should I do to change the reulting text?
You just answered your own question. Use SetWindowText() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
ytod wrote:
To talk in detail, I wanna use SetWindowText() or SetDlgItemText( ) to change the text of a control containing some text string. And what should I do to change the reulting text?
Miss one word "color":
And what should I do to change the reulting text "color"?
But I need to try what the previous post described first, thanks!
|
|
|
|
|
Using OnCtlColor() , or handling the WM_CTLCOLOR message, is the preferred method.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I need to insert a new line at the beginning of a text file but i don´t know how to do this without overwriting the first line. This is my code:
...
file.SeekToBegin();
file.WriteString(text);
...
I've also tried this:
...
file.SeekToBegin();
file.WriteString("\r\n");
file.WriteString(text);
...
but it doesn´t work. Could anyone help me? Thanks
Lucia
|
|
|
|
|
Do you have a valid file handle, do you have write-access to this file?
Check the return codes.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
It is not possible to 'insert' new data at the begining of the file. A solution for doing that is using a temporary file. In this file, you first copy the first line you need to insert, then copy all the data from the original file. When this is done, you take this data and copy it into the original file (erasing all it's previous contents).
|
|
|
|
|
I think allocating a buffer that's long enough to store previous data could also work.
|
|
|
|
|
Thanks for the reply. I have already thought of this solution but i searched the simplest one. Ok, i'll try using a temporary file
|
|
|
|
|
Be sure you have write access to the folder in which the temporary file will be created. If the file is not gigantic (e.g., 100MB or more), you could just read it into a heap-based buffer, write the new text to the file and then append the contents of the buffer. That's about as simple as it gets.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
is it possible to read icon (resource) info from an exe file directly without using resource functions such as ::FindResource()?
thx
includeh10
|
|
|
|
|
Sure, but it would require intimate knowledge of the PE file format.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have made a DSP program that reduces a wave file size.
Now i want to be able to play it on the fly as a unpack it the new soundformat.
Been trying to figure out how to play it with directsound, but havent had much luck, and resources for setting this up is sparse.
Does anyone have a working example/link/tutorial, that does the following or explains how to make it.
Takes a block of PCM data, for instance 256 bytes.
Puts it in a buffer
The audio device plays the data in the buffer without gaps.
Have some trouble getting the larger picture, of how it should be set up, from reading MSDN explanation. Im all new to directx.
Thx in advance
|
|
|
|
|
I have developed an applications (MFC Dialog based) - uses buttons, picture box, edit box and radio button (some of the buttons use a BitmapButton class).
Now I would like to turn this program into a class as I need multiple instances of it and that would be ideal just to instantiate this class as many times as needed.
How do you go about converting a program to a class where they are many files used to build the original program?
Regards,
|
|
|
|
|
make your dialog ( and all its dependencies ) a DLL.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks for the post, I have had a re-think.
As the first dialog needs to do some special processing can I create another couple of dialogs (based on the first), but with different initialisation.
i.e. can you during the MFC dialog's Init routine create another dialog
I did try but got the error:-
<code>g_pIDU[0] = this;
for(int q = 1; q < 4; q++)
{
g_pIDU[q] = new CIDU_Dlg(this);
g_pIDU[q]->Create(CIDU_Dlg::IDD, GetDesktopWindow());
g_pIDU[q]->InitNextDlg ();
g_pIDU[q]->ShowWindow(SW_SHOW);
g_pIDU[q]->SetActiveWindow();
} c:\\IDU_Dlg.cpp(734): error C2039: 'InitNextDlg' : is not a member of 'CBDialog'
Where 'InitNextDlg' is the Init for the other 3 dialogs.
|
|
|
|
|
Hi,
I have noticed a strange behaviour in my app.
I have 4 staic items:
static char* manuf[512];
static int link_man[512];
static char* comp[128];
static CDatasheet DS;
where CDatasheet is a class derived from CObject.
Filling in the manuf array, when I reach the 264th item, the app starts overwriting the memory space allocated for the DS object. So any assignment operation to that object produces an error.
Any suggestion?
Another question:
I tried to remove the DS object (commented out), but the compiler still build the app. I parsed all my files, but there are no other declaration for that object. What can it be happened?
Thanks
Dwarfpower
|
|
|
|
|
vilmer wrote:
static char* manuf[512];
vilmer wrote:
Filling in the manuf array, when I reach the 264th item, the app starts overwriting the memory space allocated for the DS object. So any assignment operation to that object produces an error.
How are you filling the array ? You know that manuf is an array of pointers, and not a string ? You have an array of 512 'strings' that are undefined (that is all adresses are invalid at the begining).
Post the code, so maybe we can help you.
|
|
|
|
|
Code is
manuf[i] = strdup("Hello");
the function provides to create a location of memory where it copies the string and writes the address of that location on the pointer manuf[i]
|
|
|
|
|
Hi all,
I have the following read/write program.
typedef struct
{
string s1;
string s2;
} Names;
int main
{
fstream fout("data.dat", ios::in | ios::out | ios::binary);
Names name;
name.s1.assign("abc");
name.s2.assign("xyz");
fout.write((char*)name, sizeof(Names));
fout.close
}
And then, I create another program to read this file
int main
{
fstream fin("data.dat", ios::in | ios::binary);
Names *name = new Names();
fin.read((char*)name, sizeof(Names));
// --> Till here, it's Ok. But if I want to access the struct. For example:
cout << name->s1.c_str() << endl;
fout.close
}
The strange thing is that, if I combine write and read file in one program, then no problem. But if I creat2 2 differenct programs, there's problems.
Can anyone help me out?
THank you in advance
|
|
|
|
|
int main
{
fstream fout("data.dat", ios::in | ios::out | ios::binary);
Names name; <--- not a pointer
name.s1.assign("abc");
name.s2.assign("xyz");
fout.write((char*)name, sizeof(Names)); <--- never thought you can cast
fout.close a structure to a pointer to
} char.
Either this works for weird reasons, or you made a mistake copying (char *)&name.
|
|
|
|
|
Recently I am writing a voice chatting program,I want to compress audio data before sending it to the other computer,could you help me?
|
|
|
|