|
DavidCrow wrote: I'm not sure what you're asking, if anything, but that produces 0xb3ed0
yes, but it gives 0x3ed0 when assigned to a 16 bit number. My doubt was about the lowest four bits, 'cause, IMHO 0x0FFF erases the highest ones. Anyway the guy was happy with your answer...
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.
|
|
|
|
|
CPallini wrote: Anyway the guy was happy with your answer...
Which was confusing as I did not answer his question exactly, and why I entertained the notion that he was confusing bits and bytes.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
ikbahrian wrote: int16_t base= 12 bit lowest 4 bits are zero
base &= 0x0FFF;
I did not test it, but what I know of bit operators it should work...
"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.
|
|
|
|
|
how would i, using the <cstring> library, delete multiple spaces in a string? eg. input = the code project rocks !. output = the code project rocks!.
|
|
|
|
|
zoobiskuit wrote: how would i, using the library, delete multiple spaces in a string?
CString::Remove is an option. But it will remove all occurances of that character from string.
|
|
|
|
|
use CString::Replace(" ", " ");
note that the first string to search for contains 2 spaces
|
|
|
|
|
You loop over the string and upon finding a space, you "eat up" all spaces following immediatly afterwards. When the next char is a non-space you continu normal operation.
"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 am not sure i know how to 'loop over a string'. i think your reply is the best for general use.
|
|
|
|
|
zoobiskuit wrote: i am not sure i know how to 'loop over a string'.
CString has the operator[], and the GetAt()-function, which additionally checks ranges.
MSDN is very clear about this.
Attention: you can not write using the operator[].
So you will need to copy to another string.
You should be able to get your assignement done by now.
Feel free to ask again when you have a implementation and it malfunctions.
"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.
|
|
|
|
|
|
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
|
|
|
|