|
I have created one static txt control and now I have to set text in multiple fonts in multiple lines
I am creating and setting fonts like that:
m_MyStaticText.Create("",WS_VISIBLE|BS_TEXT|WS_CHILD,CRect(0,0,520,58),this,IDC_STATICTEXT_PARTITION);
if (TRUE == m_font.CreatePointFont( 140, _T ("MS Sans Serif")))
{
m_MyStaticText.SetFont(&m_font);
}
m_MyStaticTextPartition.SetWindowText("\t\t\nPartition Selection");
but I have to set different font in different lines in this static text control.
So can any body tell me how it is possible.
thanks
bankey
|
|
|
|
|
Banks K wrote: how it is possible
I do not think it is. You will have to switch to a rich edit control for this, I think.
Constantly "Saving the day" should be taken as a sign of organizational dysfunction rather than individual skill - Ryan Roberts[^]
|
|
|
|
|
thanks for youe quick response.
can i set fonts for prticular line of text in rich edit text
if it is possible than please tell me...
thanks
bankey
|
|
|
|
|
Yes, you can set separate fonts for different parts of text in a RichEdit control. That can be different lines, different letters...
Answering the question of "how" is far too long to reasonably expect someone to type here for you. But a search on codeproject will help.
An article by Johan Rosengren I found very useful:
CRulerRichEditCtrl - a complete RTF mini-editor[^]
There are others in http://www.codeproject.com/richedit/[^] also.
Good luck,
Iain.
|
|
|
|
|
|
hi, anyone can help me figure out how to read data from a text file like this:
10980012907200228082002
and extract the data according to this kind of format:
Record type 1
TY-RECORD PIC (1).
ID-PARTICIPANT PIC (6).
DT-START PIC (8).
DT-END PIC (8).
i would want the program to extract the data and display them in a table, according to their fields:
TY-RECORD ID-PARTICIPANT DT-START DT-END
1 098001 29072002 28082002
and to save them in an excel format. I have plenty of record types (0 - 9) and need to display them in separate tables.
does anyone has a source code for this? or at least somebody pls guide me to figure out ways to create the program.
many thanks!
|
|
|
|
|
A handy way could be to use typedefs:
typedef struct Mytype {
unsigned int ty_recored : 1;
unsigned int id_participant : 6;
unsigned int start_pic : 8;
unsigned int dt_end_pic : 8 } Mytype;
typedef union Myunion
{
unsigned int ReadData;
Mytype ValueData;
}
Read in the lines of the file in the member ReadData of a variable of type Myunion, and get the data using the ValueData member.
Sorry for that, read Iain's post.
Or read the lines as text strings and parse them.The way you want to parse them depends on what you are using (char*, CString, or stl::string).
To save in an excel format, simply use the csv format (column value, coma, column value, coma, and so on ).
<div class='ForumSig'>Constantly "Saving the day" should be taken as a sign of organizational dysfunction rather than individual skill - Ryan Roberts[^]</div>Last modified: 50mins after originally posted --
|
|
|
|
|
If I read his question correctly, he needs to separate out the ascii represented numbers.
The struct you have described is a handy way to separate out bits of a number using bit fields. While this is v. handy for talking to hardware, I doubt it would help in this instance.
Always possible its *me* that's misreading though!
Iain.
|
|
|
|
|
Oh well, I have made too much with bitfields lately . Thanks for pointing this out Iain.
Constantly "Saving the day" should be taken as a sign of organizational dysfunction rather than individual skill - Ryan Roberts[^]
|
|
|
|
|
Read the text from the file into a CString (or char array, or std::string) -- if you can't work that out, then resign your job, or go ask your tutor...
Verify it's the right length!
If its in a CString, then you can extract bits of it using...
CString::Mid ().
So you could do...
int dt_end_pic = atol (stringWhole.Mid (1+6+8, 8));
etc.
You can do similar with std::string, and you can do it the hard with with char arrays too.
I've had to save data for excel to process before. I know there are APIs out there which tell you how to connect to Excels DOM model, etc.
I've cheated, and written out the data in CSV format, and let excel do the heavy lifting itself.
sprintf (buf, "%i,%i,%i,%i\n", ty_record, id_participant, dt_start, dt_end);
then output the string to a new file.
I hope that helped with the hard bits!
Iain.
|
|
|
|
|
mrr2 wrote: or at least somebody pls guide me to figure out ways to create the program.
Create a class that represents one of the lines:
class Line
{
public:
Line() {}
~Line() {}
private:
std::string TY_RECORD;
std::string ID_PARTICIPANT;
std::string DT_START;
std::string DT_END;
}; Then use the std::copy() function to read each line of the file into a vector of Line objects.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi All,
I have created a dialog for wizard which hosts another dialogs into itself.
Everything works fine, but it is necessary to call DoDataExchange() method of
child dialogs from within parent dialogs DoDataExchange() method.
Can anyone tell me how can I do this?
|
|
|
|
|
and why so? isn't it possible for you to call functions of Child Dialog from Parent Dialog. you have a wizard implemented. How do you implement it? Using CPropertySheet?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
OK, let me make it clear.
1. I have a child dialogs whose dialog style is set to DS_CONTROL .
2. In parent dialog's InitDialog() , I have created variables for child dialogs.
The problem is that when (in normal conditions) DoDataExchange(CDataExchange* pDX) is called, the pDX parameter is passed to it. And I think MFC does it for us.
But from within
<br />
void CDriveNewWizard::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CDialog::DoDataExchange(pDX);<br />
<br />
DDX_Control(pDX, IDC_cmdBack, m_cmdBack);<br />
DDX_Control(pDX, IDC_cmdNext, m_cmdNext);<br />
}<br />
what should I pass to child dialog's DoDataExchange() method?
|
|
|
|
|
Your query doesn't sound complete yet. Can you explain what exactly to you want to do, If you wish you can ignore the technical details for DoDataExchange for now for a better explanation of your problem.
If you want to call functions of child dialog from parent, since you have a variable(that you create in OnInitDialog() and I don't know why) when you can create it as a member variable of your class and access functions of child dialogs.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
OK.
I have created wizard according to Creating embedded dialogs in MFC article.
The author states in the article before the "Points of Interest" as follows:
"One final point to note that even though it is not in the code, from within CEmbeddedDialogDlg::DoDataExchange you should call both the m_dlg1 and m_dlg2 DoDataExchange methods."
When i want to call DoDataExchane() method of child dialog, i must pass a data
exchange variable to it, and it is not worth to pass variable of parent dialog
to child dialog.
So what should I pass to it?
May be this had made my point clear...
|
|
|
|
|
Rather than calling the childs DoDataExchange method directly, can you not do:
void CParentDlg::DoDataExchange (CDataExchange *pDX)
{
...
m_Child1.UpdateData (pDX->m_bSaveAndValidate);
m_Child2.UpdateData (pDX->m_bSaveAndValidate);
...
}
And let MFC do the heavy lifting of setting up and calling the DoDataExchage method?
Iain.
|
|
|
|
|
Oh, thanks a lot...
I guess i am new to MFC, and don't know much in's and out's...
i'm trying to learn...
Thanks a lot....
|
|
|
|
|
In addition to what Ian already stated:
From MSDN about DoDataExchange: Never call this function directly. It is called by the UpdateData member function. Call UpdateData to initialize a dialog box’s controls or retrieve data from a dialog box.
Thus, you don't call this function at all.
Depending on your design and how you use your dialogs, perhaps you shouldn't even call UpdateData either. See here[^] for an alternative.
a_b_pathak wrote:
I guess i am new to MFC, and don't know much in's and out's...
i'm trying to learn...
Then I suggest you take a look at Joe Newcomer's excellent site where he's gathered quite a few very useful tips: http://www.flounder.com/mvp_tips.htm[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hello,
can someone help me to remove a item from a vector?
I try to use vector::erase(vectoritem); but i resive an error!
Thanks
termal
|
|
|
|
|
This is not much to go on. What error message? What data types are you using for the short sample code shown?
Here is an example
<br />
std::vector<int> intvec;
<br />
intvec.push_back(23);<br />
intvec.push_back(24);<br />
<br />
intvec.erase(intvec.begin());<br />
Hope that helps.
I Dream of Absolute Zero
|
|
|
|
|
termal wrote: but i resive an error!
Which error ?
|
|
|
|
|
Hi all:
I have been given a quiz:
If I want to make a local function visible from outside of the file in which it is declared. I should make this function ________.
Can anyone help?
Thank you
|
|
|
|
|
C_Zealot wrote: If I want to make a local function visible from outside of the file in which it is declared. I should make this function ________.
Not static I guess. But I'm not sure what you mean by a local function.
codito ergo sum
|
|
|
|
|
Public ?
I Dream of Absolute Zero
|
|
|
|