|
Kevin ! Thank you... thank you very much. www.functionx.com is the cool site for me.
MilkyWay
|
|
|
|
|
Hi,
I'm currently creating a lot of ownerdrawn MFC-controls. Can anybody tell why i should use DrawItem() instead of OnPaint()?
|
|
|
|
|
for many controls, DrawItem will give you information about the specific sub-item (menu choice, list box item, etc) that you need to draw. OnPaint is for the control as a whole.
for controls that don't have sub-items, there's not much difference between the two (buttons, etc)
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Chris Losinger wrote: for controls that don't have sub-items, there's not much difference between the two (buttons, etc)
For buttons, DrawItem provides provides a lot of info that OnPaint does not, such as selection and focus state, and whether the button is up, down, disabled, ect.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
|
good morning,
anybody has experience with this? the report is txt file, everything looks just fine, but when send it to print, between some pages it would print blank pages, it didn't miss any info, but between 2&3, 3&4, 4&5 it "insert" empty page into. I have check the form feet and everything on txt file, it looks fine.
here is the print job:
if ( nPageNo > 1 )
m_Rpt->rptMessage( "\f" ); // form feed...
m_Rpt->rptMessage( m_strOrientCPI );
//do line drawings, detail headers, etc.
if ( nFirstGrpChg != -1 )
{
checkForNewPage( true );
drawBottomLine();
doDetailSummary();
drawBottomLine();
checkForNewPage( false, nFirstGrpChg );
if ( m_nCurrentPageLine == 0 )
doHeaders();
else
{
//if not a new page, still need a seperator line
fprintf(pf_rptlog,"\n" );
m_nCurrentPageLine++;
}
//call formatData here to correct witdth after footer and headers
strOut = formatData( pszData, delimiter, 0, true );
while( nFirstGrpChg < m_nDrillDownLevels )
{
drawTopLine( ( nFirstGrpChg + 1 ) );
fprintf(pf_rptlog,"%s\n",doBoinks( vholdDataHdr[nFirstGrpChg], (nFirstGrpChg + 1) ).c_str() );
m_nCurrentPageLine++;
nFirstGrpChg++;
}
drawTopLine();
doDetailHeader();
drawMiddleLine();
}
else
{
checkForNewPage( true );
if ( m_nCurrentPageLine == 0 )
{
doHeaders(); //include firstpages stuff in here
nFirstGrpChg = checkGroupHeaders( vholdDataHdr, pszData, delimiter );
loadFormat( m_currentFmt ); //this will set correct with for first grp on first page
strOut = formatData( pszData, delimiter, 0, true );
if ( nFirstGrpChg != -1 )
{
while( nFirstGrpChg < m_nDrillDownLevels )
{
drawTopLine( ( nFirstGrpChg + 1 ) );
fprintf(pf_rptlog,"%s\n",doBoinks( vholdDataHdr[nFirstGrpChg], (nFirstGrpChg + 1) ).c_str() );
m_nCurrentPageLine++;
nFirstGrpChg++;
}
}
drawTopLine();
doDetailHeader();
drawMiddleLine();
}
else
{
strOut = formatData( pszData, delimiter, 0, true );
}
}
m_bFirstGrpLine = false;
if ( m_nFrameGroup != -1 )
{
strOut = doBoinks( strOut ); //getBoink() + strOut + getBoink();
}
fprintf(pf_rptlog,"%s\n",strOut.c_str() );
m_nCurrentPageLine++;
if ( m_nCurrentPageLine == ( m_nPageLength - 1 ) )
doFooter();
|
|
|
|
|
Have anybody seen any examples or source code how to make toolbar for Outlook Express?
|
|
|
|
|
See Demo toolbar for OE
http://www.plugins-soft.com/demos.html
BUT this commercial source.
|
|
|
|
|
Hi I'm trying to do the following:
1) generate a random # from the array layer_array[]
2) swap the number generated with a negative number, to avoid repetition of that random #.
I'm not sure I'm correctly sampling from layer_array[]. And I'm definitely not implementing swap() correctly....how would i proceed?
Please help.
<br />
#include <cmath><br />
#include "stdafx.h"<br />
#include <ctime><br />
#include <cstdlib><br />
#include <algorithm><br />
#include <fstream><br />
#include <iostream><br />
#include <iomanip><br />
using namespace std;<br />
<br />
int main()<br />
{<br />
const int size = 20;<br />
<br />
int layer_array[size]={0};<br />
<br />
for(int i=0; i<size; i++)<br />
layer_array[i]=i+1;<br />
<br />
srand((unsigned)time(0)); <br />
<br />
int random_integer[size] ={0};
<br />
for(int index=0; index<size; index++)<br />
{<br />
random_integer[index] = (rand()%size)+1; <br />
swap(&layer_array[index],&layer_array[index*-1]);
<br />
cout << random_integer[index] << endl; <br />
}<br />
<br />
return 0;<br />
}<br />
|
|
|
|
|
aaadetos wrote:
swap(&layer_array[index], &layer_array[index * -1]);//error c2664
I'm curious what you are expecting to swap with this. You typically don't dereference an array using a negative number.
By the very definition of random, uniqueness is not a quarantee. Therefore, you can't get a random number that is guaranteed to not repeat. If you do, then it is not random. However, if you are simply wanting a list of unique numbers returned to you in a pseudo-random order, that is a different beast altogether.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I'm curious too! According to the code presented, [index * -1] would result in an illegal array index value, except for index=0.
INTP
Every thing is relative...
|
|
|
|
|
you say you have a c2664 compiler error, ,but does it say exactly ?
C2664 is : 'function' : cannot convert parameter number from 'type1' to 'type2'
please tell the entiere error message, ,otherwise it doesn't mean anything for us...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
One way to obtain an array of random numbers with none repeating is as follows:
Since your random number is to be in the range 1-n, it is better to simply initialize an array of size n with the numbers 1-n:
for (int i = 0; i < size; i++)<br />
layer_array[i] = i + 1;
(BTW for peformance, don't initialize the array first with "{0}" since you are immediately initializing it one line later.)
Now, seed the random number and then go through the array again exchanging every value with the value at a randomly selected offset:
for (i = 0; i < size; i++)<br />
{<br />
int dst = rand() % size;<br />
<br />
int tmp = layer_array[i];<br />
layer_array[i] = layer_array[dst];<br />
layer_array[dst] = tmp;<br />
}
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi
I'm not sure what u mean:
(1) to fill an array with non-repeating random numbers
or (2) to shuffle array elements
From your code it looks more like 2. It also looks like the [Delete] was pushed here and there...
The technique of marking used elements is not good. If u had an array of 1M the last iteration would lots of time coz u'd repeat it lots of time till u hit the one out million left..
What u should do is this:
<br />
int i, new_array[size], old_array[size];<br />
<br />
for(i=0; i<size; i++)
init(old_array+i);<br />
<br />
for(i=0; size>0; i++) {<br />
new_array[i] = old_array[x=(rand()%size)];<br />
<br />
old_array[x] = old_array[--size];<br />
}<br />
HTH
Yakov
-- modified at 10:07 Thursday 27th October, 2005
|
|
|
|
|
I am new to the use of sockets, ports and client/server applications.
I have an application that will Connect to a proxy server (to allow for remote commands).
However if the server is temporarily lost (unexpectedly) how do I detect it returning?
My application continues to run but never re-Connects to the server.
Does the server notify me? if so how?
Should I use GetPeerName or can I continually try to Connect to an already connected port
I have a 2 minute timeout timer that I intend to use as a Connect retry control but I need to know when to start.
I am using Visual Studio 6 and VC++
|
|
|
|
|
cgb143 wrote: However if the server is temporarily lost (unexpectedly) how do I detect it returning?
If a socket connection is closed, you need to reinitiate it. On TCP/IP level there is no notification when another peer is back "online" after the connection is closed, you could try to reconnect in intervalls or work out a protocol where the server activly sends something (like a broadcast inside a LAN). Make sure you don't flood the network with wild/endless reconnect attempts, e.g. give up after the 10th reconnect attempt. Hope it helps.
|
|
|
|
|
i'm trying to implement a button that functions for example the way that the seek or pitchbend controls function on a cd player. that is, you press/'push' it and 'work starts getting done' and 'stops getting done' when/after you release the button.
the only way that i know and that works is to check mouse coordinates upon WM_LBUTTONDOWN/UP (since WM_COMMAND gets sent only after you press and depress a button) and compare them with the button position/recantgle and then take appropriate action... but that seems too complicated (calculating, storing & comparing coordinates), is there a simpler way ?
thnx
|
|
|
|
|
There are lots of button examples here.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
Anonymous wrote: i'm looking for a perhaps simpler/more efficient method (and with using just win32) ...
While only partially related, have you seen this?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: While only partially related, have you seen this?
hmm thanks for the link but i can't find the handling of WM_LMBUTTONDOWN (and checking if it's for the desired button) in the shown code of that example... am i blind or is it somehow hidden/already implemented by mfc ?
i found a different approach, explained here http://www.pluralsight.com/articlecontent/cpprep0797.htm[^]. it seems simpler and more logical but to implement it for this purpose the button control, that is it's window, should have it's own window procedure which i could then override to handle WM_LMBUTTONDOWN/UP messages... so my question is do even the buttons have a window procedure ?
although when i think about it this approach also isn't as straitforward as it looks, at least not for what i need to use it. in the new wnd procedure i would then have to call GetParent() and then send a message to the parent dialogbox which would then again have to be processed by the dialogbox procedure ...
in your opinion, which method is more efficient then ?
|
|
|
|
|
|
Hi
I am a student.When I do my homework,i encounter a problem.I can not get
the actual value in VisualC++.
The question is how to get 95.123 raised by 12.
Maybe I haven't explained my mean.Sorry about my poor English!
Thanx first!
-- modified at 1:49 Thursday 27th October, 2005
|
|
|
|
|
What are you speaking about ?? What means " 95.123 's 12th power " ?? And what are you trying to do exactly and what is the exact problem encoutered ?
Try to be more specific.
|
|
|
|
|
The question is how to get 95.123 raised by 12.
Maybe I haven't explained my means.Sorry about my poor English!
|
|
|
|