|
The problem is probably coming from the way you're handling the return value from the rand() function, which returns a value in the range 0 to RAND_MAX . Try using the following:
a[i] = (rand() * 59) / RAND_MAX;
Software Zen: delete this;
|
|
|
|
|
hi, thanks for the reply.
i try the method of yours and it still output same numbers in draw.
|
|
|
|
|
|
aaaah.....that happenz coz the random function that uses this.....is not a good function to be used.....
try something like using the system time and date and feeding it to a ur own random number generator based on this.....
that ought to help.....
happy programmin.....
cheerz.....
|
|
|
|
|
What you have appears to be fine. srand() is called correctly, which is what most folks fail to do when seeing the same numbers over and over. You should be getting six pseudo-random numbers in the 1-59 range.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I want to make a server client program that administers all computers in a network. The problem is that I don't know how to get all the computers on a network. Can someone tell me if are there any projects here that might help ?
Thanks.
gabby
|
|
|
|
|
See the WNetOpenEnum , WNetEnumResource and WNetCloseEnum functions.
|
|
|
|
|
Thank you very much. Te functions worked fine. I really needed to get the IP of each computer in the network and if I use gethostbyname() associated with a computer name retreived it does not work. I need to get the ip's. can you tell me how can I get the IP of a computer on the network if I know the host . Thank you very much for you answer that helped a lot too. thanks.
gabby
|
|
|
|
|
Hello,
I have made an richtexbox(not multilined) using the RICHEDIT_CLASS. And basicly what I want to ask is; When the richtextbox is in focus how can I there make my application know if I hit Return? Since its only one line I can´t check for '\n'´s.
I am working VS.NET 2003 and using Win32 API.
I hope I´m clear enough otherwise feel free to ask.
Thanks.
|
|
|
|
|
If nothing else works, PreTranslateMessage will do it:
pMsg->message == WM_KEYDOWN
and
pMsg->wParam == VK_RETURN
|
|
|
|
|
Hi,
How can i Set Ethernet adapter (NIC) NDI Params from application ( C/C++ ),
Params are ConnectionType, EnableTagging, VLANID etc'.
|
|
|
|
|
I hope all tree items on context window of html help are expanded when the help pops up.
normally tree items of context window are collapsed.
do you know how to do that?
thx
includeh10
|
|
|
|
|
Check out this website.
http://www.mvps.org/htmlhelpcenter/
I found the sample projects to be useful even though the tutorials are not that great. I was looking at htmlhelp recently and did not get much help from the newsgroups nor could I find much on the web. But the C++ example here was quite useful, so you can download it, compile it, and use the debugger to figure out what is going on.
When you use the htmlhelp api to to tell your program to display a particular help file, within the htmlhelp window, it will expand the table of contents for you. I don't do anything specific to make it happen; it just does it. I implemented context help to allow me to press the '?' button on the upper right of my window and then when you select a dialogue item, it will call the html api function like so...
That is one example; you might have switch statements or some pattern for interpreting the ID of the resource and then calling the appropriate version of ::HtmlHelp. Notice the '::'. I am using the global api function. There is an HtmlHelp function built into the mfc classes as well and I do not use those. I use the global function. Why? Cause it just works for me, I guess.
Here is some example code. You see I am responding to the OnHelpInfo method in my dialog class. I setup the help path to my .htm file and then when I call ::HtmlHelp at the bottom, it will open the main html help window with the table of contents displayed and it will expand them to the file I am telling it to display specifically.
Hope that gets your started. That's all I know; and the htmlhelp documentation, that I have found, really stinks. So I learned how to do things using the example code on the aforementioned website. I still have no idea how it really works.
BOOL CDataReductionDlg::OnHelpInfo(HELPINFO* pHelpInfo)
{
CWinApp* theApp = AfxGetApp();
//Get the help file name
CString sHelpFilePath = theApp->m_pszHelpFilePath;
//sHelpFilePath += _T("::/hid_sc_size.htm");
switch(pHelpInfo->iCtrlId)
{
case IDC_START_DAY:
case IDC_SPIN_START_DAY :
case IDC_START_HOUR:
case IDC_SPIN_START_HOUR:
case IDC_START_MINUTE:
case IDC_SPIN_START_MINUTE:
case IDC_START_SECOND:
case IDC_SPIN_START_SECOND:
case IDC_START_MILLISEC:
case IDC_SPIN_START_MILLISEC:
case IDC_END_DAY:
case IDC_SPIN_END_DAY:
case IDC_END_HOUR:
case IDC_SPIN_END_HOUR:
case IDC_END_MINUTE:
case IDC_SPIN_END_MINUTE:
case IDC_END_SECOND:
case IDC_SPIN_END_SECOND:
case IDC_END_MILLISEC:
case IDC_SPIN_END_MILLISEC:
case IDC_STATIC_FILESTART:
case IDC_STATIC_FILESTOP:
sHelpFilePath += _T("::/task_ex_time_segments.htm");
break;
case IDC_BROWSE_INPUT:
case IDC_FILENAME_OUTPUT:
case IDC_BROWSE_OUTPUT:
case IDC_FILENAME_INPUT:
sHelpFilePath += _T("::/task_ex_file_selection.htm");
break;
case IDC_JMSG_FILTER :
case IDC_GWMSG_FILTER:
sHelpFilePath += _T("::/task_ex_using_filters.htm");
break;
case IDC_CANCEL_BUTTON:
case IDC_START:
sHelpFilePath += _T("::/task_ex_output_desc.htm");
break;
default:
break;
}
//If no additional topic was appended to the help path, then the default
//topic will be displayed.
::HtmlHelp(m_hWnd,
sHelpFilePath,
HH_DISPLAY_TOPIC,
NULL);
return TRUE;
}
|
|
|
|
|
digwizfox,
really thans for your long reply.
i will try your comments soon.
cheers.
includeh10
|
|
|
|
|
Hi,
I want to select a particular part of the image by drawing a frame around them(like in paint brush) or by clicking on two points on the image to indicate the range of selection. I do not know how to do it in VC++ and also I am using CXIMAGE for processing images. Please do help me, I know this is big...but please give me some tips.
Thanks in advance
|
|
|
|
|
I met with the same problem
I wonder if someone got the solution,or the update vision has new functions about that,
for I'm just starting with this class,hope someone can give some clues for that.
Appreciate!
modified on Monday, July 20, 2009 8:34 AM
|
|
|
|
|
I am writing a small test app' and while trying to debug I get the message "Please enter the path of the vc60.pdb" when I select my /debug folder it then shows "A file with the correct name was found, but it is not the correct one." Anyone got any idea what project settings are causing this?
|
|
|
|
|
hi,
I do also get this message when doing my project, even though the file is actually present in your DEBUG folder. Click on CANCEL button on the message box of "PLEASE ENTER THE PATH OF VC60.PDB", then it will work. Do not worry, this will never show up in the executable file. Hope this works for you...as it does work for me.
Good Luck
|
|
|
|
|
Thanks. That is what I did, but why does it happen and how are you supposed to resolve it properly so it doesn't keep happening?
|
|
|
|
|
Try doing a 'rebuild all'. I've also seen this occur when the file was marked readonly, and didn't get rebuilt properly.
Software Zen: delete this;
|
|
|
|
|
hi!
i have made an application in visual c++ which contains two dialog boxes each with different contents.... i have also added a menu which interchanges the two dialog boxes... in the menu i have added two tabs one named normal and the other named special.... the two dialog boxes have the id's IDD_NORMAL AND IDD_SPECIAL....for normal tab i have added text
EndDialog(IDD_SPECIAL);
int result=IDD_NORMAL;
CDialog dlg(result);
result=dlg.DoModal();
and approximately the same code for Special tab....
the problem is that for the first time the dialog box works fine ie it interchanges but when again i wish to change the dialog , the other one remains and doesn't end.... wat should i do and yeah as i have written the code with the help of somebody ... i don't know the meaning of the statement
CDialog dlg(result)
please do explain
thankyou
haseeb
|
|
|
|
|
I hope you did not write it as shown in this post. The idea I gave you should have worked, here is a rewrite (of an dialog-app InitInstance fuction):
BOOL CVeryTemporaryApp::InitInstance()
{
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls();
#else
Enable3dControlsStatic();
#endif
int nResponse = IDD_NORMAL;
while (nResponse == IDD_NORMAL || nResponse == IDD_SPECIAL)
{
{
CVeryTemporaryDlg dlg((UINT)nResponse);
m_pMainWnd = &dlg;
nResponse = dlg.DoModal();
}
}
return FALSE;
}
In the above example: the response from DoModal() should be IDOK, IDCANCEL, IDD_NORMAL or IDD_SPECIAL, anthing else is invalid.
As for EndDialog(IDD_SPECIAL), this causes dlg. DoModal() to return IDD_SPECIAL as the response code.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
please can anybody tell me how to control the execution speed of a processing loop regarless of the cpu speed for the machine?
i am working on a program that animates pictures, and when i move the program to a computer with fast cpu it executes too fast, the animation is destroyed!
timers dont work well for they cant respond for less than 50 ms.
i need an effective control over my code execution speed.
any feedback is welcome.
thanx all
Mohammad Gdeisat
a candle looses nothing by lighting another candle
|
|
|
|
|
i think that you should make a counter for the number of pics dislayed in the current second, if the couunter is greater then , let's say 25, do nothing. If a second elapsed reset the counter to 0 and do the same process...
actualy this must work because is a graphics technique
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
This problem is as old as computers. We used to write code to do everying thing as fast a possible, because they where to slow. Now they are to fast.
1) You could do your animation in a seperate thread and use Sleep().
You might start by looking up "thread classes" in the MSDN library, then go onto look at other methods of handling threads.
2) (NO LONGER RECOMMENDED - BUT WORKS)
An older method that is not used much any more (I think) is to handle message passing in your own proccessing loop. This method has been used offten in game programing.
int Wait(DWORD dwDelay)
{
clock_t nGoal = clock() + dwDelay;;
if( PeekMessage(&msg,NULL,0,0,PM_REMOVE) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if( msg.message == WM_QUIT )
return -1;
.....
if( clock() >= nGoal )
break;
}
return 0;
}
void ShowAnimation(...)
{
....
ShowFirstFrame(...);
for( ;; )
{
ShowNextFrame(...);
...
if( Wait(...) < 0 )
break;
}
}
This sample above uses the clock function but you could also use the mulimedia timer (See "Using Multimedia Timers" in MSDN).
How you apply apply the message passing code in your own code is up to you.
------------------------------------------------
Well that enough, there are probably other ways to accomplish this.
P.S. There are lots of sights (and books) dedicated to game programing and animation.
Good Luck!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|