|
Hehehe, I got you by a minute!
I see dumb people
|
|
|
|
|
I've found a mathematical formula to do this now. It assume zero mean and it is written in MatLab.
sigma = 2; %The std deviation<br />
x1 = rand(1000,1); %Linear rand number between 0.0 to 1.0<br />
x2 = rand(1000,1);<br />
<br />
z = sqrt(-2*sigma*log(x1)) * cos(2*pi*x2);
the log here is ln, that is log to the base e. Now all we need is just to put it in C.
Thanks to all who replied my post.
|
|
|
|
|
You can use the code you listed to generate normal variates, but I believe you will get garbage out in the tails of the distribution. The random number generator that is packaged with C is not very good. I suggest you find a better one...there are plenty of them out on the web.
Here is an example
http://www.cs.wm.edu/~va/software/park/park.html
Gary Kirkham
A working Program is one that has only unobserved bugs
|
|
|
|
|
Thanks for the suggestion. I look into it.
|
|
|
|
|
I am trying to do a grid on a window, but it's not working right.
It is a MDI program using MFC.
When I scroll the window by clicking on the scrollbar(pagefull), it works fine
When I scroll by clicking on the scroll arrow, no new grid lines get drawn
When I scroll by dragging the scroll button, only some new grid liens get drawn
I have made the window using the CS_HREDRAW | CS_VREDRAW class style.
The window is made of 1026x1026 tiles, each tile being 16x16 pixels
CRect r;<br />
VERIFY(dc.GetClipBox(&r) != ERROR);<br />
<br />
CBrush *b = new CBrush(theApp.m_gridColor), *ob;<br />
CPen *p = new CPen(PS_SOLID, 1, theApp.m_gridColor), *op;<br />
<br />
ob = (CBrush*)dc.SelectObject(b);<br />
op = (CPen*)dc.SelectObject(p);<br />
<br />
x = r.left >> 4;<br />
x2 = r.right >> 4;<br />
y = r.top >> 4;<br />
y2 = r.bottom >> 4;<br />
<br />
<br />
for (Sint32 i = x; i < x2; i++)<br />
{<br />
dc.MoveTo(i << 4, r.top);<br />
dc.LineTo(i << 4, r.bottom);<br />
<br />
if (i % theApp.m_thickGridInterval == 0)<br />
{<br />
dc.MoveTo((i << 4) + 1, r.top);<br />
dc.LineTo((i << 4) + 1, r.bottom);<br />
}<br />
}
|
|
|
|
|
How to detect whether the balloon tips of tray icon has been clicked or timeout on Win2K?
On WinXP, I can receive the message NIN_BALLOONTIMEOUT and NIN_BALLOONUSERCLICK when balloon hide because timeout or click on it. But on Win2K, I have got nothing.
Advise please.
Thanks in advance!
Sincerely yours,
Forrest;P
|
|
|
|
|
It's better idea to get the position of the icon on system tray.
Please advise how to get the position.
Thanks.
Forrest
|
|
|
|
|
How can I check if there is one thread from an application run now?(Not my own application,for example Outlook express is run now or not)
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Probably what you mean is if atleast one application instance
is running ?
What you need is to just enumerate the process list
and look at the exe or the program name.
Process32First, Process32Next.
|
|
|
|
|
Thanks,I'll take alook at them.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Is there any way that I can find out I'm connected to internet or not in my application?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
I've already answered this question, but here is it again:
#include <ras.h>
bool IsConnected()
{
LPRASCONN TRasCon;
RASCONNSTATUS Tstatus;
DWORD lg;
DWORD lpcon;
bool lReturn;
TRasCon->dwSize = 412;
lg = 256 * TRasCon->dwSize;
lReturn = false;
if( RasEnumConnections(TRasCon, &lg, &lpcon) == 0 )
{
Tstatus.dwSize = 160;
RasGetConnectStatus(TRasCon->hrasconn, &Tstatus);
lReturn = ( Tstatus.rasconnstate == 0x2000 );
}
return( lReturn );
}
But this time I will say it's not my code!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Thanks Rickard.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
You must also want to try InternetGetConnectedState.
|
|
|
|
|
Hello, folks,
I am looking for a Win32 API to do disk formatting, i.e, formatting hard disk to FAT or FAT32 or NTFS format.
What Win32 API should I use ? Anybody know ?
Thanks ! Any response would be appreciated !
|
|
|
|
|
Sorry, I never really got down to that level
Good luck!
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Say I'm creating an MFC-based MDI application with Document-View architecture. When I compile and run the basic code provided by the AppWizard, I get a main frame with a new document child frame already open in the main frame. But my program will not have support for ID_FILE_NEW. I only want the user to be able to load pre-existing documents. How do I prevent the program from starting with a new empty document?
|
|
|
|
|
You can normally use this in your Apps InitInstance
// stop a new document being created if just run normally
if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing ;
just before the call to ProcessShellCommand()
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
Go to your app's InitInstance() method and comment out this bit of code:
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (!ProcessShellCommand(cmdInfo))
return FALSE;
he he he. I like it in the kitchen! - Marc Clifton (on being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Hi everyone. Now I know how to select a row in code, so here is another similar question. I have a listview on a dialog, and the first row in the list view is selected on oninitdialog (there is always entries in the list view). Problem is, I don't want the list view to deselect the row if the user clicks whitespace (such as blank area below the last row in the list view). Usually the listview deselects any rows when this whitespace is clicked. I tried the following code, the idea being keep the last row selected before whitespace was clicked, so in effect you can never deselect a row:
<br />
void CMyDlg::OnClickLvwEmails(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
<br />
iSelected = m_lvwEMails.GetNextItem(-1, LVNI_SELECTED);<br />
if(iSelected == -1)<br />
{<br />
m_lvwEMails.SetItemState(m_iPreviouslySelectedItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);<br />
}<br />
else<br />
{<br />
m_iPreviouslySelectedItem = iSelected;<br />
}<br />
*pResult = 0;<br />
}<br />
This seemed to work, except when the user clicks on the list view in the exact same spot twice with the mouse. Then the last row highlighed would be deselected. But if you click different areas in the whitespace, it keeps the last selected row selected. Anyone know a better way to do this? Thanks!
|
|
|
|
|
Anonymous wrote:
except when the user clicks on the list view in the exact same spot twice with the mouse
Perhals it is because in that case the notification message send to the dialog is not the same, like a double click or LVN_BEGINLABELEDIT/LVN_ENDLABELEDIT ?
I hurt so bad inside
I wish you could see the world through my eyes
It stays the same
I just wanna laugh again
|
|
|
|
|
i am working a VC++ graphics project which is not having
any browse information. If i make changes (selecting Browse info from settings,& build project) it gives me error
as
Error executing bscmake.exe.
what are the posiible problems & solutions.
also if project is ported from vc5.0 to vc 6.0
browse info file gives problem?
pls help me
|
|
|
|
|
i want to create a plug in in vc++ for internet explorer..can it be done and how?please help..
himanshu
|
|
|
|
|
Check Google for "Browser Helper Object", I don't have any special link in mind now
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have a question:
what is the difference bettwen DECLARE_DYNCREATE(CCtrlView) and DECLARE_DYNAMIC(CView).
when and where to use them?
thanks
|
|
|
|