|
thanks finally
i got some good stuff
Vikas Amin
Embin Technology
Bombay
|
|
|
|
|
Hi all:
I have a tree control with checkbox inside dialog and I added the following message map:
ON_NOTIFY(NM_CLICK, IDC_TREE1, &CCheckBoxDlg::OnNMClickTree1)
And before the CCheckBoxDlg::OnNMClickTree1 finish. I've counted all the checked child items which belonging to specific parent. But it seems that the CTreeCtrl class doesn't take the items I've just check/unchecked into consideration before the NM_CLICK finish. In other words, I always get the item's previous check/uncheck value. How can I do my part after the check/uncheck default processing finished, but still inside NM_CLICK?
|
|
|
|
|
i havea class in my local main int i am trying to make a for loop to look for a empty class to put my data in
grahpic_card gc[10];
int i;
for(i;i<10;i++)
{
if(gc[i].model=="")
{cin>>gc[i].model;}//by the way model is an char[50]
}
but this does not work since the object was created as a local is there any way to make this work?
|
|
|
|
|
I would like to suggest you to buy a good book on C++ and read it
-Prakash
|
|
|
|
|
I suggest Bruce Eckel
yeh its and author name , i dont know if the spell is wrong.
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
He needs it not me.
-Prakash
|
|
|
|
|
Ok prakash
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
|
The MSDN docs say "The path can be specified as a Unicode string or a PIDL" for the BFFM_SETSELECTION message (inside a BrowseCallbackProc function after calling SHBrowseForFolder), but when I send a Unicode string instead of an ansi one it fails. Is the documentation wrong?
|
|
|
|
|
Did you set the wParam as true?
-Prakash
|
|
|
|
|
yep, it works fine with an ansi string.
|
|
|
|
|
How are you sending the unicode string ? can you dump the section of code ?
-Prakash
|
|
|
|
|
if you uncomment the commented out lines it works fine in unicode builds but not ansi. it's being converted to unicode ok because OutputDebugStringW prints what it's supposed to.
int CALLBACK BrowseCallbackProc_SetInitFolder(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
if (uMsg == BFFM_INITIALIZED)
{
SendMessage(hWnd, BFFM_SETSELECTION, TRUE, lpData);
}
return 0;
}
|
|
|
|
|
In Ansi build you should NOT convert the string to Unicode while using windows APIs,
Check this link[^] and search for BFFM_SETSELECTION
The Microsoft documentation has a couple of minor errors I should point out in case you try to program SHBrowseForFolder in C. The documentation says to pass the string for BFFM_SETOKTEXT in WPARAM; actually, it's LPARAM. It also says that BFFM_SETSELECTION requires a Unicode string, but BFFM_SETSELECTION is available in both A and W flavors, so you can use LPCTSTR.
-Prakash
-- modified at 23:38 Sunday 8th January, 2006
|
|
|
|
|
Mr.Prakash wrote: The Microsoft documentation has a couple of minor errors
ah, thats what i thought. thanks.
|
|
|
|
|
i was just wondering if this is possible?:
i have 2 class
and each of them i declared 10 object and 1 pointer:
grahpic_card gc[10],*ptr_gc;
mother_board mb[10],*ptr_mb;
is there a way i can store any one of the pointer in 1 pointer something like this
???? *ptr1;
instead of having to use 1 pointer for each of the class i would like to use 1 pointer for BOTH of the class is that possible if so please teach me how
|
|
|
|
|
You need some understanding of C++.
use a baseclass from which graphic_card and mother_board will be derived from.
for example
class Mother_board :public Base
and
class Graphic_card :public Base
Then
Base *base;
Mother_board *mBoard;
Graphic_card *gCard;
<<<assumeing that="" the="" mboard="" and="" gcard="" are="" initialed.="">>>
then
base = mBoard or <<< you can use reinterpret_cast too >>>
base = gCard is valid assignmnet.
add virtual or pure virtual methods in both base and derived class so that you can call the methods as base->foo();
-Prakash
|
|
|
|
|
reinterprit_cast
is the key word
but its not that simple
as u feel as c++ doesnot
like such type casting and
might lead u some error in
programe if reiterprit is not
used with proper cution .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
dynamic_cast can be used for better safety.
-Prakash
|
|
|
|
|
The applicaiton is ok in Windows 2000.
When run in Windows Xp ,at the beginning there is a error which said the memory could not be visited.
I link WS2_32.LIB in the project.
Why?
Thanks!
|
|
|
|
|
rushing wrote: The applicaiton is ok in Windows 2000.
Is it your application?
Is it memory exeception? if it is written by you can u identify the code from where the memory exception is raised?
-Prakash
|
|
|
|
|
I just realized the Point class does not provide the = operator. Now that I'm trying to actually use GDI+ in my apps, I'm finding the classes for Rect, RectF, Point, and PointF to be rather peculiar in design.
Also, Rect doesn't provide functions that return the endpoints.
I can't create an Array of Point and copy another Point into one of it's elements (unless it's during initialization). Instead, I have to resort to assigning the X and Y members explicitly into each array element.
I'm not sure if there is some bigger picture I'm missing here or some new highly ultra OOP paradigm I missed the whitepaper on or if this design is just weak and missing some of the useful operators that MFC provided on many of it's classes.
Does anyone have any insight concerning these omissions in some of the more basic classes like Point and Rect? My code just looks rather bloated copying the members individually like this so I thought maybe I'm doing it wrong.
Thanks in advance for any guidance.
-- modified at 21:59 Saturday 7th January, 2006
|
|
|
|
|
I want to build a win32 console program in VC .Net. I wrote one function in random1.h and random1.cpp, Then, I wrote my main program in SimMCMain.cpp which call this function from random1.h and random1.cpp. It's no problem in VC++ 6.0, but it always has problem when linking in VC.Net. Can anyone give me some suggestion? Thanks
****random1.h***
#ifndef RANDOM1_H
#define RANDOM1_H
double GetOneGaussianBySummation();
double GetOneGaussianByBoxMuller();
#endif
****random1.cpp****
#include <cstdlib>
#include <cmath>
// the basic math functions should be in namespace
// std but aren't in VCPP6
#if !defined(_MSC_VER)
using namespace std;
#endif
double GetOneGaussianBySummation()
{
double result=0;
for (unsigned long j=0; j < 12; j++)
result += rand()/static_cast<double>(RAND_MAX);
result -= 6.0;
return result;
}
double GetOneGaussianByBoxMuller()
{
double result;
double x;
double y;
double sizeSquared;
do
{
x = 2.0*rand()/static_cast<double>(RAND_MAX)-1;
y = 2.0*rand()/static_cast<double>(RAND_MAX)-1;
sizeSquared = x*x + y*y;
}
while
( sizeSquared >= 1.0);
result = x*sqrt(-2*log(sizeSquared)/sizeSquared);
return result;
}
****SimMCMain.cpp ****
// requires Random1.cpp
#include <Random1.h>
#include <iostream>
#include <cmath>
using namespace std;
double SimpleMonteCarlo1(double Expiry,
double Strike,
double Spot,
double Vol,
double r,
unsigned long NumberOfPaths)
{
double variance = Vol*Vol*Expiry;
double rootVariance = sqrt(variance);
double itoCorrection = -0.5*variance;
double movedSpot = Spot*exp(r*Expiry +itoCorrection);
double thisSpot;
double runningSum=0;
for (unsigned long i=0; i < NumberOfPaths; i++)
{
double thisGaussian = GetOneGaussianByBoxMuller();
thisSpot = movedSpot*exp( rootVariance*thisGaussian);
double thisPayoff = thisSpot - Strike;
thisPayoff = thisPayoff >0 ? thisPayoff : 0;
runningSum += thisPayoff;
}
double mean = runningSum / NumberOfPaths;
mean *= exp(-r*Expiry);
return mean;
}
int main()
{
double Expiry;
double Strike;
double Spot;
double Vol;
double r;
unsigned long NumberOfPaths;
cout << "\nEnter expiry\n";
cin >> Expiry;
cout << "\nEnter strike\n";
cin >> Strike;
cout << "\nEnter spot\n";
cin >> Spot;
cout << "\nEnter vol\n";
cin >> Vol;
cout << "\nr\n";
cin >> r;
cout << "\nNumber of paths\n";
cin >> NumberOfPaths;
double result = SimpleMonteCarlo1(Expiry,
Strike,
Spot,
Vol,
r,
NumberOfPaths);
cout <<"the price is " << result << "\n";
double tmp;
cin >> tmp;
return 0;
}
|
|
|
|
|
Pierre,Hsieh wrote: but it always has problem when linking in VC.Net.
"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!
|
|
|
|
|
SimpleMCMain1 error LNK2019 and
SimpleMCMain1 fatal error LNK1120
|
|
|
|