|
Hi thanks
Do you mean outside the class or outside the onmouseover? It is actually outside the onmouseover and inside the class.
Do you mean declaring as public variable? What kind of type of variable shld I use? CArray <codata,codata>? The VC++ doesnt allow me the declare this type.
Someone in the forum mentioned to create another header file and include it before declaring it. I got a lot of errors after I did that.
|
|
|
|
|
i compile a COM then use it (by Windows).
when i try to re-compile it, VC said "can not open file ..."
it means VC can not delete it for generating a new one.
i try to delete the COM manually from Explorer but failed.
after use Regsvr32 to unregister the COM, i still can not delete the COM.
i have to restart my PC for any code modifications.
How to solve the problem?
thx
includeh10
|
|
|
|
|
Are you AddRef 'ing and Release 'ing the COM object correctly in your application? It could be that the object's ref count never got cleared, and the object won't remove itself because of it.
Bob Ciora
|
|
|
|
|
Hi Bob,
thanks.
I am testing a sample downloaded.
the sample uses a ref count (ULONG m_uRefCount) initialized as 1 in construct;
in AddRef(), the count inc 1;
in Release(), the count dec 1;
in QueryInterface(), it may inc 1;
is the idea right?
details are in followings:
----------------------------------------
//construct
CContextMenu::CContextMenu()
{
m_uRefCount=1;
}
STDMETHODIMP_(ULONG)CContextMenu::AddRef()
{
return ++m_uRefCount;
}
STDMETHODIMP_(ULONG)CContextMenu::Release()
{
if(--m_uRefCount==0)
{
delete this;
return 0;
}
return m_uRefCount;
}
STDMETHODIMP CContextMenu::QueryInterface(REFIID iid,LPVOID FAR*ppv)
{
m_uRefCount++;
if(IsEqualIID(riid,IID_IUnknown))
{
*ppv=this;
return NOERROR;
}
else if(IsEqualIID(riid,IID_IShellExtInit))
{
*ppv=(LPSHELLEXTINIT)this;
return NOERROR;
}
else if(IsEqualIID(riid,IID_IContextMenu))
{
*ppv=(IContextMenu*)this;
return NOERROR;
}
else
{
m_uRefCount--;
*ppv=0;
return ResultFromScode(E_NOINTERFACE);
}
}
m_uRefCount is NOT used by other placess.
what is wrong?
|
|
|
|
|
Isn't it a shell exension? (what I can guess from the code). In that case the explorer.exe holds your dll. You need to kill the explorer process somehow - first method is to simply kill it in taskman, but there's some other method - after you do ctrl-alt-del, but I can't remember it now - check the codeproject's page about shell extensions.
|
|
|
|
|
Can anybody tell me why this won't break out of the for() loop when it returns -2. Or any other suggestions.
#include <iostream>
#include <cmath>
#include <time.h>
using namespace std;
int playRockPaperScissors();
double calculateWinRatio(int,int);
int didUserWin(int,int);
int main()
{
int roundScore,
totalGames,
wins;
double winRatio;
totalGames=0,
wins=0,
roundScore=0,
winRatio=0;
cout << "Welcome to Rock, Paper, Scissors.\n"<< endl;
for (;;)
{
roundScore = playRockPaperScissors();
if ( roundScore == -2 ) break; // break out of loop if user wants to
}
winRatio = calculateWinRatio(wins, totalGames);
cout << "The Ratio of Wins to Losses is: " << winRatio << endl;
return 0;
}
int playRockPaperScissors()
{
int userChoice,
computerChoice,
did;
userChoice=0,
computerChoice=0;
cout << "\nRock = 1"<< endl;
cout << "Paper = 2" << endl;
cout << "Scissors = 3" << endl;
cout << "Enter your choice (0 to quit). \n \n" << endl;
cin >> userChoice; // get user's choice here
srand(time(NULL)); // seed a random number based on time
computerChoice=(rand()%3+1);// gets the number to guess 1 to 3
if ( computerChoice <= 1 && computerChoice >=3) // this if statement
checks the input
{ cout << "ERROR\n";
return -2;
}
if ( cin.bad() || cin.fail() ) // this if statement checks the input
{ cout << "Invalid Input. \n";
return -2;
}
if ( userChoice>=4 || userChoice<=-1) // this if statement checks the
input
{ cout << "Invalid Input. \n";
return -2;
}
if ( userChoice == 0) // this if statement checks the input
{ cout << "Quit already." << endl;
return -2;
}
did=didUserWin(userChoice, computerChoice);
return did;
}
|
|
|
|
|
First off....
if ( computerChoice <= 1 && computerChoice >=3 )
{
cout << "ERROR\n";
return -2;
}
Can never succeed. computerChoice can never satisfy both conditions of the && . Try an OR instead:
if( (computerChoice <= 1) || (computerChoice >=3) )
But here's your real problem:
if ( userChoice>=4 || userChoice<=-1 )
{
cout << "Invalid Input. \n";
return -2;
}
if ( userChoice == 0 )
{
cout << "Quit already." << endl;
return -2;
}
You need to be checking for characters, not integers. Change it to this, and it should work fine (note the comparison changes):
if ( userChoice > '3' || userChoice < '0' )
{
cout << "Invalid Input. \n";
return -2;
}
if ( userChoice == '0' )
{
cout << "Quit already." << endl;
return -2;
}
Hope it helps!
Bob Ciora
|
|
|
|
|
Actually, scratch my other post (except the part about checking the computer's code...the && logic is still incorrect). Just add one line at the specified position as shown:
userChoice -= '0';
if ( userChoice>=4 || userChoice<=-1)
{
cout << "Invalid Input. \n";
return -2;
}
Bob Ciora
|
|
|
|
|
Can not debug from ASP.NET (local) ...
- a usual COM component.
i.e. web-service called, debugged,
but not enters to native code of COM component.
why so?
How to resolve ?
Thanks
I set option Remote Debugging by DCOM,
but studio falls
|
|
|
|
|
I use a CToolBar control in a dialog to load a bitmap as a group buttons.
And if I use the dialog as main dialog (pop up dialog), the toolbar can work normally,
but question is: if a use the dialog as a child window (WS_CHILD), created by a parent dialog.
then the toolbar can't be used.
I find the way to update dialog UI, but it can't work.
So I think some messages to the dialog filtered by its parent window. But I can't find them, and get a solution:confused:.
If you can solve the problem:laugh:, or give me some tips:zzz:! Thannks Very Much!
skybird
|
|
|
|
|
I have big problem:
when I use CToolBarCtrl. I load a bitmap as a toolbar, and set button size as size (16, 15). At the beginning, the program run normally, but sometimes, the toolbar's button change bigger,
I don't know why.
The details link is:
http://www.codeproject.com/miscctrl/PropEditor.asp
Maybe if you are a guru:cool:, or want have a try:^). Help me! Thank you very much!;P
skybird
|
|
|
|
|
hello
i would like to load a bitmap and get pixels values to put in an array. my source code is
int main()<br />
{<br />
Cximage image;
image.load("C:\\monimage.bmp", CXIMAGE_FORMAT_BMP);
if (!image.Isvalid)
{ cout<<"probleme lors du chargement"<<endl;}
return 0;<br />
}
somebody can help me?
what librairies can i use?
thanks
|
|
|
|
|
hello,
i want to add a password to a .exe file,when run the .exe file ,popup a dialog and ask the password first,if password is right then run the true .exe file,how can i do it?
|
|
|
|
|
I think there is a easy way to do that. At the beginning of you code, you can add the code to
show the password dialog, if password true, run continuously, if not exit.
skybird
|
|
|
|
|
Depends on how secure you want it. This method can be bypassed in less than ten five minutes
modified 12-Sep-18 21:01pm.
|
|
|
|
|
hello,
i do not know what is your meaning,do you meaning to insert the code to the PE file of the .exe file?if it,how to add the code to the .exe file?
thanks.
|
|
|
|
|
|
Hello,
Is there a way to "edit" the contents of this list. What I want, is to remove some duplicated items. (read below)
I have set the Visual Studio IDE to remember the 10 last solutions I have opened. (which saves me a lot of time in navigating to them:-> ) <font color green>[Tools->Options, Environment, General: Display [ ] items in most recently used lists]</font>
The problem arises if I open a 'copy' of a solution just to compare some stuff, and I will get a duplicated solution name, and I need to be careful not to open the incorrect one.
Any hint?
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
My articles
|
|
|
|
|
for VS2002 the list is stored in the registry under HKCU\Software\Microsoft\VisualStudio\7.0\ProjectMRUList. I would assume VS2003 would be the same.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Thanks,
The key for VC 7.1 is HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1\ProjectMRUList
Now, the list is organized as follows:
<font color=black><br />
<ul><br />
Key Value<br />
File1 Path to first sln file<br />
File2 Path to second sln file<br />
File3 Path to third sln file.<br />
...<br />
FileN Path to N'th sln file.<br />
</ul><br />
</font>
Is it possible to delete a pair without renaming the following keys?
(delete key "File2" but preserve the rest, is renumbering required?)
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
My articles
|
|
|
|
|
rbid wrote:
Is it possible to delete a pair without renaming the following keys?
I just tried, and the result is that VC will truncate the list at the first
empty place, that is, if you delete item3, (File3 key), the start page will only
show the first two items.
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
My articles
|
|
|
|
|
This is really bugging me... I can remember coming across an API several months ago that is like MessageBox() but it also puts a "don't show me this again" checkbox in the dialog, and automagically maintains a registry entry that holds the checkbox state. Now that I want to use this function, I can't find it. I thought it was a SHXxx or ShellXxx one (maybe one of the settlement APIs) but I've had no luck. Anyone know what I'm talking about here?
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
|
|
Michael Dunn wrote:
No, it was an API, not an article.
Are you sure? Memory can be a tricky thing.
http://www.codeproject.com/dialog/xmessagebox.asp[^]
If you are correct that there is a windows API that does this be sure to let us know what it is when you find it.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|