|
int iLineNumber;
CString strLine;
//////////////////////////////////////////////////////////////
// Get the currently selected line number.
//////////////////////////////////////////////////////////////
iLineNumber = m_edit.LineFromChar(-1);
//////////////////////////////////////////////////////////////
// Get the text of the current line number.
//////////////////////////////////////////////////////////////
strLine = m_edit.GetLine(iLineNumber);
If you have just a normal CEdit control then GetWindowText will
get ALL the text for you.
Also of interest are LineIndex and LineLength.
Note that some of these methods return the 'position' in the string
where the new lines are and NOT the 'line number'.
Jules
|
|
|
|
|
This is an extreamly newbie question. New to C++ and Visual C++.
I need to write a progra, that can be used a a math tutor for a young student
The program has to display 2 random numbers that are to be added, such as:
247
+129
-----
The program has to pause while the student is working on the problem. When the student is ready
to check his or her answer, a key can be pressed and the program will display the correct Solution.
247
+129
-----
376
It should then Say : Timmy you got it Right! Or Timmy, thats not the right answer, Try again.
NOTE:Forgot to mention, that it needs to ask for the users name :P
Some help would be apperciated.
|
|
|
|
|
Suppose you have to generate numbers in the range [100, 500]
Then you could write something similar to:
// initialize random number generator
// otherwise every time the app is run
// you get the same numbers
srand((unsigned)time(NULL));
int a = 100 + rand()*(500-100)/RAND_MAX;
int b = ... // the same
The function rand() returns an integer in the range [0, RAND_MAX] so you have to adjust the result to fit your range. Another possibility, if your range is much smaller than RAND_MAX, is to write:
int a = 100 + rand()%(500-100);
I don't know which is best.
Cheers,
Paolo.
|
|
|
|
|
Does anyone knows where I could find an example on Multidimentional CMap. What I am trying to accomplish is the following:
Example:
Department ASD
Workers
Worker 1
Worker 2
Worker 3
Department Accounting
Workers
Worker 1
Worker 2
Both of these should be searchable by string. To accomplish the inner dimmention I have done the following:
CMap < CString, LPCSTR, CWorker, CWorker > m_Worker;
I have tried to get the outer dimmention with the following:
CTypedPtrMap < CMapStringToOb,CString, CMap < CString, LPCSTR, CWorker, CWorker > > m_Department;
where CWorker is a class containing two _bstr_t for the first and last name.
The error I was getting was that the CMap does not have a copy constructor. Does anyone knows how to accomplish this that is clean and logical?
Thanks for your help, John.
|
|
|
|
|
Try something like:
typedef CMap<cstring, const="" char*,="" cstring,="" char*=""> lower_map;
CMap<cstring, const="" char*,="" lower_map*,="" lower_map*="">;
That should work.
|
|
|
|
|
Hi, I've been trying to implement a floating palette bar, ala Photoshop with MFC, alas, to no avail.. the examples from Microsoft, CtrlBar & cmnctrl1 i think.. don't quite fit with code generated using MFC Wizard. Can anyone point me to a sample code that implements this feature using code generated with MFC Wizard?
Thanks.
|
|
|
|
|
maybe you should check out what christian just posted as a project ... seems a good starting point if not a solution to your problem
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Thanks for the plug
I was going to suggest the same, although for my paint program I actually use a modeless dialog for a floating palette, the CGSToolbar certainly has pretty much everything you'd need to make a dockable toolbar that shows colours - I use it for that in a toolbar that shows the current selections.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
<<< In the name of GOD >>>
Hi.
I have question about Owner-Draw ListBox.
I added Owner-Draw with my ListBox, and use of color and icon in ListBox.
My problem is, when i add a string with ListBox i can't see string !!!
ATTENTION 1: i can see icon or color in ListBox
My source code in Owner-Draw :
void CHlistbox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rc = lpDrawItemStruct->rcItem;
UINT action = lpDrawItemStruct->itemAction;
if(action & ODA_DRAWENTIRE)
{
pDC->FillSolidRect(rc,RGB(20,10,5));
}
}
ATTENTION 2: I add string when dialog want to load
My source code about adding a string with ListBox :
BOOL CListBoxDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
m_listbox.AddString("Hadi");
return TRUE;
}
Please help me ... or send to me FULL example about Owner-Draw in ListBox
Hadi Rezaie
|
|
|
|
|
I believe owner drawn mrans YOU have to output the string.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
what christian means hadie is that the strings should be drawn AFTER you fill the color in or you are overwriting your text with the color
i think
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Hi all,
I'm kinda new here and was hoping someone could help me out with a problem. I have a combobox and I want people to be able to select from the combo box with the mouse, by clicking on it, but not scroll through the combobox with the keyboard... so if they click on the combo box and make a selection I dont want them to be able to then scroll down the combobox with the arrow keys. Any advice would be appreciated.
Thanks,
--Dave
|
|
|
|
|
This sounds to me like a colossally bad idea ( changing default behaviour so your combo will not behave as your user expects ), but assuming you have a good reason to do it...
From what I can see, you'll need to create a class derived from a combo box. Then you can capture the key press for the arrows and ignore it. OR you could catch ON_CBN_DROPDOWN, and set a bool to tell you if the list has been dropped, and based on that in ON_CBN_SELCHANGE you can know if the selection change is from an arrow press or list box click. Sounds like a lot of work to me, but that's how I would do it ( probably just the first suggestion )
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
One way you could do this is to derive a class off of CComboBox, overide the PreTranslateMessage function and add code like this:
if (GetDroppedState() && (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP || pMsg->message == WM_CHAR))
return TRUE;
Just my 2cents worth.
|
|
|
|
|
How can I show Modaless Dialog and stop the treatment of the CView (I have leftView and View) when Modaless´ Cancel button is clicked. Thanks. I´m desperate.
|
|
|
|
|
I'm not sure what you are asking ?? To show a modeless dialog, you would make a pointer to one a member variable so you can create it and it won't go out of scope. I tend to put
If (Create(IDD, pParent))ShowWindow(SW_SHOW);
in my constructor so that creating my modeless dialog also shows it. In order to do something in your main view based on the pressing of cancel, you would override OnCancel and do whatever you want there. For example, you could write a function in your mainframe that does what you want, and call it like this
CMainFrame* pMain = (CMainFrame*) AfxGetMainWnd();
pMain->MyFunkyFunction();
I posted an answer yesterday where I showed how to get pointers to view and doc objects also.
Hope that helps.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Hey guys,
Once again I need your help. I am desiging this funky gui control that requires me to create this odd region for buttons. Basically take a square and superimpose a circle in the center offset from the borders of the suare by 5 pixels. Got a vague picture in your head?
Ok now with that picture in your head, think of the space left at each of the 4 corners...there are my button regions that i created. Now my next hurdle is to overlay a bitmap over that region.
Any ideas on how i could do it? It has to be possible.
Thank you for any input
"DWORD my man!"
|
|
|
|
|
Use SelectClipRgn on the Device context of the Bitmap Button Control and BitBlt the Bitmap on to it.
Subbi.
|
|
|
|
|
Is it possible to take an existing MFC based app (say something based on MDI) and wrap it into an OCX for placement in a web browser? I know we'd have to do some things to de-MFC/MDI some of the application but is there somewhere to look for at least how perhaps we could approach this if it is even possible???
Thanks!
|
|
|
|
|
even if you could the size of the resulting activex would be so huge nobody would want to download it probably
maybe use atl instead?
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Please, help me! How can I show Modaless Dialog and stop the treatment of the CView (I have leftView and View) when Modaless´ Cancel button is clicked. Thanks.
|
|
|
|
|
What's a No Modal dudette? DO you mean a modeless dialog?
|
|
|
|
|
yes, I am so sorry. I was thinking in a modeless dialog. Ups!
|
|
|
|
|
am very sorry but your english makes it impossible to understand what you are asking ... is there anyway you can write it better?
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Yeah, I know this is trivial,
But does anyone know how to calculate the orthodox and nonothodox Easter Friday Dates From a Year Value.
I'm thinking it could make a Kool Easter Egg system to implement
Regardz
Colin Davies
Ownguide NZ
|
|
|
|