|
|
read the other answers. looping manually is not a good idea when the class itself already provides a way to do things...
read CString::Replace() for more infos.
|
|
|
|
|
toxcct wrote: ooping manually is not a good idea when the class itself already provides a way to do things...
Right.
But your Replace(" ", " ") will not find any number of whitespaces.
So depending on the situation, you would have to use Replace in a loop until it returns zero.
And that is ugly...
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
jhwurmbach wrote: But your Replace(" ", " ") will not find any number of whitespaces
yes it does !!! have only tried ? me did !
|
|
|
|
|
toxcct wrote: yes it does !!! have only tried ? me did !
No, it doesn't !!! Yes. Me too!
Do you want my (VS2003) solution or is it enough to say that a string containing 6 spaces in a row between letters after applying Replace( " "/*Two spaces*/, " "/*One space*/) contains three spaces.
And that Replace (correctly) returns 3?
You are right in that it is always better to use the libraries given (and to know ones tools).
But here we only have a library-function that does something similar to what we (maybe) want.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hi all:
Is there any existing matrix library and ODE solver in VS2005.NET? Or if somewhere else? I have got the book "numerical recipes in c++", or should I code the program by myself according to the algorithms introduced in the book?
Thanks
Asura
|
|
|
|
|
I think that book comes with source code (maybe also you can find it online).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Check out the standard header <valarray> and Boost's uBLAS[^] library.
Steve
|
|
|
|
|
I'm creating an additional window from my base CDialog application:
//m_dtarray[] keeps pointers
m_dtharray[i]=(CDialogThread*)AfxBeginThread(RUNTIME_CLASS(CDialogThread),THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
m_dtharray[i]->m_pt_winpos.x=x; //window pos
m_dtharray[i]->m_pt_winpos.y=y;
m_dtharray[i]->ResumeThread();
...and created window doesn't get focus. I tried to add something like this:
m_dtharray[i]->m_pMainWnd->SetFocus();
or
m_dtharray[i]->m_pMainWnd->SetForegroundWindow();
...but it doesn't help, still my window doesn't get focus (new window's name is blinking on taskbar). Window is created in OnInitInstance() in this way. (error checking skipped)
CTWindow *m_wnd=new CTWindow();
BOOL ret=m_wnd->Create(IDD_TWINDOW, NULL);
m_wnd->SetWindowPos(&CWnd::wndTopMost,m_pt_winpos.x,m_pt_winpos.y,0,0,SWP_NOSIZE);
m_wnd->ShowWindow(SW_SHOW);
// SetForegroundWindow(m_wnd->m_hWnd); //THIS DOESN'T HELP TOO....
// m_wnd->SetFocus(); //NEITHER THIS....
m_pMainWnd=(CWnd *)m_wnd;
m_wnd->m_ParentThread=this;
How can I set window focus?? (from main application or from newly created window, it doesnt matter)
Strange thing is, that when I run this code from VS2003 it's getting focus(?!?!) but when run from icon, it doesn't get...
Do You have any idea why??
Thanks for help
Pat.
|
|
|
|
|
PatrykDabrowski wrote: Do You have any idea why??
Read this article, Using Worker Threads[^] what your trying to do is always going to be problematic.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
Thanks! After couple of articles descibing this 'bug' I have successfuly tested this solufion:
Instead of using plain SetForegroundWindow()/SetFocus() I use this:
//Attach
AttachThreadInput(GetWindowThreadProcessId(::GetForegroundWindow(),NULL),GetCurrentThreadId(),TRUE);
//Do our stuff
SetForegroundWindow();
SetFocus(); //Just playing safe
//Detach the attached thread
AttachThreadInput(GetWindowThreadProcessId(::GetForegroundWindow(),NULL),GetCurrentThreadId(),FALSE);
...and it's working fine! (on winXP)
|
|
|
|
|
i need to draw a rgb histogram for an image file in vc++.
Where can i find a code for it?or where can i find guidance regarding algorithm.
|
|
|
|
|
allocate 3 integer arrays of 256 elements (one each for R, G, and B). initialize them all to 0.
foreach pixel in the image
{
RedArray[pixel.red_component]++
GreenArray[pixel.green_component]++
BlueArray[pixel.blue_component]++
}
|
|
|
|
|
Thanks, now how do i draw it on screen?
|
|
|
|
|
pick a rectangle on-screen, that's 256 pixels wide.
find the largest value in all your histograms, max_val
for each histogram, start at 0, go across the rect, drawing lines ((rect_height / max_val) * cur_histo_val) high.
|
|
|
|
|
Thanks a bunch
|
|
|
|
|
[Sorry for the reposting, i posted using the wrong title]
Hi all,
Im looking at developing a program that simply keeps a log of which users have accessed a specific program, i.e. Program icon is clicked, then a log is updated with user details i.e. Who last used the program, IP address, User name etc etc.
Any ideas? Getting the user details shoud be faily easy..
Many Thanks
Karl
|
|
|
|
|
karldwmoore wrote: accessed a specific program
And you can't alter that program?
Then I'm out of luck.
Maybe you can have a service running that hooks the mouse and finds out if a mouseclick is going to an applicaltions icon, but...
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
I have access to the program, i just need to keep track of which users have been running the program..
|
|
|
|
|
karldwmoore wrote: i just need to keep track of which users have been running the program..
Use GetUseName[^].
|
|
|
|
|
prasad_som wrote: Use GetUseName[^].
Sorry.
I found this so obvious, I didn'n think that he was missing this bit of information.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
In tree control how do I set different color for each tree item text.
i.e.
Root
Item1 with one color
Item2 with another color
Sachin
|
|
|
|
|
Handle NM_CUSTOMDRAW and you can set the color on a per-item basis
|
|
|
|
|
Hi,
I am developing a application in which I need to draw the some text and graphics on the view. I can do this in OnPaint as well as in OnDraw. But when one should use OnPaing and when OnDraw()? What is difference between OnPaint and OnDraw?
Regards,
Hemant Kulkarni.
|
|
|
|
|
OnDraw() is ultimately called by OnPaint() , as you can find inside MFC sources:
void CView::OnPaint()
{
CPaintDC dc(this);
OnPrepareDC(&dc);
OnDraw(&dc);
}
There you can also see what happens inside OnPrepare() .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|