|
double width = 19.2;
int intWidth = (int) width ;
int widthIntRemainder = (int) width % 6;
double actualRemainder = width - intWidth + widthIntRemainder;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Don't use modulus?
double width = 19.2;
double remainder = width - ((int)width / 6) * 6;
Todd Smith
|
|
|
|
|
I have add some CommandBars to my MFC application, like in the tutorial 'Using Windows CE CommandBands in an MFC based Application' (http://www.codeproject.com/ce/commandbar.asp) from Bruce Hearder.
It works fine, but after opening the 'Save as..." dialog from the main menu and closing that all CommandBars will be removed (or hidden ?!?).
I have 3 CommandBars on the top of the MainFrm-Window. So, when I am click the 'Save as..." menu item the 'Save as' dialog will be opening. So, after choosing OK or CANCEL of the 'Save as' dialog, the dialog will be close. After that all CommandBars will be removed (destroyed or hidden?!?!?).
Can anyone help me!?!?!
(I use eVC++ 3.0 and the Emulator - no device at the moment)
--
Nice greets, Daniel.
|
|
|
|
|
hi,
I am using a SDI FormView-derived Form. I am dynamically creating controls which are placed on the form.
I need to resize the vertical size of the form as I fill it. I have placed a scroll bar on the form.
I managed to do the following:
void CStocks: nSize(UINT nType, int cx, int cy)
{
CFormView: nSize(nType, cx, cy);
CRect txtRect, clientRect;
GetWindowRect(txtRect);
ScreenToClient(txtRect);
GetWindowRect(clientRect);
CStatic caramba[50];
CString g;
for (int i=0;i<50;i++)
{
g.Format("%d", i);
caramba[i].Create(g, WS_CHILD|WS_VISIBLE|SS_CENTER|WS_BORDER, CRect(10, i*10, 120, i*10+50), this);
txtRect.bottom += 50;
}
MoveWindow(txtRect);
As you can see I created quite a few objects just to test the scroll facility. The Scroll Bar appears but my Toolbar and Statusbar disappeared.
Can anyone help me with an example or correction of my errors.
Thanking you in anticipation.
Rui
|
|
|
|
|
GetParentFrame()->RecalcLayout();
ResizeParentToFit(FALSE); Maybe one of these two sentences (or both combined) gives some results.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hello!
i make a vc++ programm with a mdi. everytime, when i start the programm a empty document is open. what must i change, that the empty document is not there at the beginning?
thanks
MFC is the best
|
|
|
|
|
Find the code:
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
and add:
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
i ask the same question a few hours ago, sorry, and the person who answerd me said something like that, too. i tried your version, but it doesn't work. i don't know why, the empty document still come at the beginning.
do you have another idea, or did i made a mistake??? i found the code in: programmname.cpp!!!!
hope you can help me.
|
|
|
|
|
Post the code from CYourApp::InitInstance
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
everything is okay.....i found the mistake....thank you very much!!!!!!
|
|
|
|
|
Any help would be appreciated.
cheers
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Have you tried GetDlgCtrlID(hWnd) ?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
That'll do for me.
Cheers
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
What kind of object do you have a handle to? For example, you could use DWORD GetWindowThreadProcessId() for a window.
-----
DWORD GetWindowThreadProcessId(HWND hWnd, LPDWORD lpdwProcessId);
-----
Kuphryn
|
|
|
|
|
I need the following
- sorted container of items, sorted based on a function that compares the objects and returns true/false.
- access to the container based on index. container[index] or something similar.
- insertion, search by value and querying are all of almost equal frequency
What container do you guys suggest for this?
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Do you forsee the container fluctuating heavily in size, or remaining constant? IE is there some maximum number of records? Will you always insert at one of the ends of the container, or possibly in between?
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
In most situations, the insert will occur at the end, because it is a sequence of objects sorted on time - but I could get an out-of sequence object once in a while, which should be inserted in between.
The container will grow in time, chances of shrinking is 0.
I was thinking about vector. Then I do a compare with the last item and if it is supposed to be at the end, then i push back. If it requires to be inserted somewhere else I push_back and call a sort. I get indexed access to the list
If I use set, I will have automatic sorting. But, then how do i get indexed access? Forwading an iterator?.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
You must forward an iterator to access items in a set.
vector, deque, and string are the only containers that have random access iterators.
From what you've described, it sounds like vector is the way to go. Also, if you haven't used STL containers before, I think vector would be the best to start with because it is the one you will most often use.
Lan
|
|
|
|
|
I have used both set and vector before, but wanted to get a second opinion on this because it is quite a performance-critical section in the code. I was leaning towards vector because of the random access part, but the only thing that made me think was the sorting part since set does it automatically on insert. .
Guess I was trying to be lazy here.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Hey, nothing wrong with being lazy!
I think that is at least half the reason I use the STL.
Lan
|
|
|
|
|
I would have to agree. The only problem with vector is that it is implemented as a contiguous block of memory, like an array. If you keep growing the vector, it becomes expensive to keep adding elements since it has to constantly keep allocating and moving things around to keep it contiguous. A list would solve that, but of course you lose the random access iterator. In addition, repeated sorts on a vector consume more CPU cycles than say a list since a vector has to shuffle data around whereas a list would just shuffle pointers.
Use reserve() right away with your vector to pre-allocate a specific number of elements. This will save time overall since it can immediately allocate its chunk in one fell swoop as opposed to constantly having to re-allocate and move the existing chunk every time you do a push_back as the vector begins to grow. If you have a rough idea of how many elements will be required, you can play with this reserved amount to get the right mix of as few resizes as possible during the life of the vector.
For example, if you grow your vector from 1 to 1024 elements, it would take 11 resizes if no initial reserve is set. If you set the reserve to 512, there would only be two resizes. The disadvantage is the "wasted" memory as the vector grows to reach 512 elements. Memory versus CPU time is the age-old quandary
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
Thomas George wrote:
If it requires to be inserted somewhere else I push_back and call a sort. I get indexed access to the lis
Don't sort every time you add - this gives you O(n*log(n)) complexity, which will be a performance killer. Assuming that vector is sorted before insertion, you may find the right place for insert in O(n) time. std::upper_bound even will find the index for you.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
that is cool!
I never used upper_bound before because i never knew that I can use a predicate for comparison.
Thank you
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
You could use a vector of pointers to your objects. That way resizing the array doesn't get to costly.
Todd Smith
|
|
|
|
|
They are already pointers.
But, Thanks for the reply
I lOVE CP. Always gets so many tips and suggestions.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|