|
rand()/RAND_MAX.
Not exactly working. Integer arithmetic here.
-- modified at 14:13 Monday 10th October, 2005
|
|
|
|
|
The best you can hope for is a pseudo-random number. Use rand() for this?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I want to get a random number between 0 and 1.Can you help me?Thanks a lot.
|
|
|
|
|
Did you try the rand()[^] function? It returns an int, but you can always divide the resulting int by pow(10, sizeof(int) + 1) to get a number between 0 and 1.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
std::rand() / (double)RAND_MAX gives a uniformly distributed random number in range [0...1]. Following function gives a uniformly distributed value in half-open range [lo…hi).
template <typename T>
inline T random(T lo, T hi)
{
return (T)(lo + (__int64)std::rand() * (hi - lo) / (RAND_MAX + 1));
}
Seppo
-- modified at 9:09 Monday 10th October, 2005
|
|
|
|
|
How about 1 divid by the system generated random number?
So, if the system generated number is
10 => 1/10 = 0.1
100 -> 1/100 = 0.01
& etc.
|
|
|
|
|
Hi,
I have a dialog that I have created through MFC wizard in which I have a CStatic control placed. I do not want minimize/maximize button in the dialog, however I want the window to be maximized when I clicked on minimized dialog and minimized when I click on the activated window icon in the status bar in Windows Explorer.
Can anyone suggest How I can implement this?
I am new to MFC so apologies if this question seems too trivial!!
Thanx in advance.
Mandira T
|
|
|
|
|
Hi Mandira,
I was working around your problem.
I have tried doing it using WM_SIZE message..but am not able to get the exact results.
then i tried doing it using MoveWindow function
void CMinMaxDlgDlg::OnButtonMaximize()
{
// TODO: Add your control notification handler code here MAX
CRect rect;
CWnd* pWnd = GetDesktopWindow();
pWnd->GetClientRect(rect);
MoveWindow(0,0,rect.Width(), rect.Height(),TRUE);
}
this code will make ur dialog box size same as that of desktop window
now if u want to restore it to the original state then u will have to store the original length, width and start x and y coordinates of dialog box.
thn handle it in OnButtonResize() function likt this
OnButtonResize()
{
MoveWindow(startx, starty , initialwidth, initialHeight, TRUE);
}
but am not able to minize it completely
Let me know if this helps you !
Ashwin
|
|
|
|
|
I understand you want to click the title bar to maximize the dialog on the screen, then you want to click the icon in the task bar to retrieve the original size and position of the dialog.
For that you have to do the following:
Declare the following handlers for your dialog class:
====================================================
afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
Add the following message map entries:
=====================================
ON_WM_NCLBUTTONDOWN()
ON_WM_ACTIVATEAPP()
Call GetStartRectangle() within OnInitDialog()
Declare and define the following:
====================
void CYourDlg::GetStartRectangle()
{
CRect rcArea;
int w, h;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rcArea, 0);
GetWindowRect(&m_rcInitial);
w = m_rcInitial.Width();
h = m_rcInitial.Height();
m_rcInitial.left = (rcArea.left + rcArea.right) / 2 - w / 2;
m_rcInitial.right = m_rcInitial.left + w;
m_rcInitial.top = (rcArea.top + rcArea.bottom) / 2 - h / 2;
m_rcInitial.bottom = m_rcInitial.top + h;
}
void CYourDlg::Maximize()
{
CRect rcArea;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rcArea, 0);
MoveWindow(&rcArea);
}
void CYourDlg::Minimize()
{
MoveWindow(&m_rcInitial);
}
void CYourDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
if ( nHitTest == HTCAPTION ) Maximize();
CDialog::OnNcHitTest(point);
}
void CYourDlg::OnActivateApp(BOOL bActive, HTASK hTask)
{
Minimize();
}
SkyWalker
-- modified at 5:47 Monday 10th October, 2005
|
|
|
|
|
Hello:
I am a little project where I have to take RichText(RTF) input, and then draw it out using GDI+. The user able to change text format in middle of the text string just like VISIO 2003. The RTF able to rotate and translate using GDI+. If anyone know about any article or code snipe that I could look at it.
Thank You.
|
|
|
|
|
Is it good programming, blocking of thread with event->Lock() instead of using
::WaitForSingleObject() function.
NSS
NSS
|
|
|
|
|
sthalasayanam wrote:
event->Lock()
Is a MFC way to force Thread in Waiting state and..
sthalasayanam wrote:
::WaitForSingleObject() function.
It Is win32 way to Force Wait for thread....
About good Programming practice.. it depends on company to company... as both are equally good.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Well, the ::WaitForSingleObject API function is more versatile, in the sense that it accepts a variety of handles and works for all of them.
That said, if all you want is event based waiting, you might as well use CEvent and Lock.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thnaks for your answer.
NSS
|
|
|
|
|
The USB flash disk have no CHS parameters (the system use virtual parameters),I only need to get teh total sectors,how to do it? Thanks.
|
|
|
|
|
Anonymous wrote:
The USB flash disk have no CHS parameters (the system use virtual parameters),I only need to get teh total sectors,how to do it? Thanks.
Would calling GetDiskFreeSpace[^] and then computing TotalNumberOfClusters * SectorsPerCluster do the trick?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Does that include the boot sector?
Me, wrong!?! Nah, you just need to change your thinking to make me right.
|
|
|
|
|
I want to get the total sectors for physical drive. The MBR and BOOT may be failure. so your function is invalid. Could tell me the other function? Thanks.
|
|
|
|
|
My brain's melting!
Can I use an XOR ROP on text? Erasing and re-drawing (moving) it like I'd do with a Rectangle or Ellipse and an R2_NOT ROP.
TIA, Simon.
|
|
|
|
|
I believe you need to draw it onto a bitmap first.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I want to use LAPACK's math library.
|
|
|
|
|
Is there any way to still purchase VS6? I have nothing against .net, I simply am used to VS6. I got a new PC and my VS6 CD no longer works. It would save me lots of time if I could just buy another copy of VS6. Thanks!
Me, wrong!?! Nah, you just need to change your thinking to make me right.
|
|
|
|
|
|
do you want a Copy of VC6 without license?
I can Send it for you.
you may only pay its post expense & 1$ for its CD.
Iman Ghasrfakhri
-- modified at 15:23 Monday 10th October, 2005
I'm ashamed For this suggest, I think you can yous this copy insted of your CD.
|
|
|
|
|
Ghasrfakhri wrote:
you may only pay its post expense & 1$ for its CD.
Watch Buddy .. Priacy on open Forum is not allowed...
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|