|
Just to determin whether that was indeed problem, I got rid of the dynamic allocation of memory to that array. Instead, I set it to a fixed array size when its declared. But I still get that windows error message.
|
|
|
|
|
Can someone explain PostNcDestroy()? I saw it in some sample code, and I tried to look it up but couldn't quite understand the need for it.
|
|
|
|
|
I'm running a thread that constantly checks GetCurSel() to make a comparison. The problem occurs when I click the arrow on the droplist and move the mouse over selections. Before actually clicking to select something, the GetCurSel() seems to be returning the value that the mouse is highlighting. Is that correct? Shouldn't GetCurSel() return the actual value selected? How can I solve this?
|
|
|
|
|
acerunner316 wrote: I'm running a thread that constantly checks GetCurSel() to make a comparison. The problem occurs when I click the arrow on the droplist and move the mouse over selections. Before actually clicking to select something, the GetCurSel() seems to be returning the value that the mouse is highlighting. Is that correct? Shouldn't GetCurSel() return the actual value selected? How can I solve this?
Polling the GUI constantly is probably not what you want to do. Instead, try caching the value you need to compare within your thread and create an even for it to check on each interval to see if he needs to update its value. When you change the selection in the ComboBox, trigger the event.
Alternatively, you could also create a variable that is shared between the GUI thread and the other thread and set its value when there is a new selecting in the combo box. You will need to use Critical Sections for either of these solutions, though.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
If you just need to know when the selection changes, you should handle CBN_SELCHANGE - no need to do something as complex as a polling thread.
|
|
|
|
|
acerunner316 wrote: I'm running a thread that constantly checks GetCurSel()...
Does this thread own the UI control? Only the owning thread, which is usually the primary thread, should be interacting with the UI controls.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
what do you mean "own the UI control"? The thread begins on initialization of the window. And runs continuously with a sleep(10).
Anyways, I've already tooks Zac's advice and stored a variable. That's what I was going to do, but that involved changing a lot of code, so i was hoping there was another way to do it. It's probably the best way though.
|
|
|
|
|
acerunner316 wrote: what do you mean "own the UI control"?
UI controls (e.g., buttons, listboxes) are owned by a thread, usually the primary thread. Folks new to multi-threaded programming often make the mistake of having secondary threads communicate directly (e.g., SendMessage() ) with those UI controls. Nasty things happen as a result.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
acerunner316 wrote: what do you mean "own the UI control"? The thread begins on initialization of the window.
When a control is created, it is created within the context of a thread (usually the main thread is the only one that deals with UI stuff -- with VERY rare exceptions).
acerunner316 wrote: And runs continuously with a sleep(10).
As a side note, anytime you are calling Sleep , you really need to take a closer look at your design. You should almost never have to call that function. See below for a better solution.
acerunner316 wrote: Anyways, I've already tooks Zac's advice and stored a variable.
Make sure you wrap any reads/writes to that variable with Critical Sections (in both the UI and worker threads). Also, to eliminate the need for the thread to be constantly running (and calling Sleep , add an event that you will signal after changing the variable in the UI thread. In the worker thread, call WaitForSingleObject on that event.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
If the item's in your list are unique, you could work around this using:
CString value;<br />
m_combo.GetWindowText( value );<br />
m_combo.FindStringExact(-1, value );
Or you could cache the selected index in a member variable in your SelChange handler.
I'd probably go with option 2.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I want to use CreateService() with SC_MANAGER_CREATE_SERVICE as last argument.
The user haven't administrative rights.(Not an admin)
Is SetNamedSecurityInfo() usefull?
If(YES)
how?
else
what's the solution?
In VC6 please
|
|
|
|
|
RomTibi wrote:
I want to use CreateService() with SC_MANAGER_CREATE_SERVICE as last argument.
The user haven't administrative rights.(Not an admin)
for installing of service, user should have admin rights or you can use LogonUserEx to logon as admin and install the service
<div class='ForumSig'>"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 Support CRY- Child Relief and you </div>
|
|
|
|
|
There are applications - like antivirus software for ex. - that can work like services. That apps. work under every account. Isn't it true? This is the kind of thing I want to do.
|
|
|
|
|
RomTibi wrote: There are applications - like antivirus software for ex. - that can work like services. That apps. work under every account. Isn't it true? This is the kind of thing I want to do.
there is quite difference in working and creation of service... services can work in any account.. even when user is no logged i.. but it could be created with admin priviledge
"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
Support CRY- Child Relief And you
|
|
|
|
|
Thanks.
I'll study VC Forum Q&A :- I/ IV
|
|
|
|
|
Hello can anyone please help me.. i want to get the Dimensioned Bitmap from CBitmap ,
like i have a .bmp (bitmap) of 400 x 300 dimensions image.
and i want to show the 20x20 area of image and then 40x30 can anyone tell me how to extract the dimensioned bitmap..
like i try SetBitmapDimensions(int dwWidth , int dwHeight ) but its does not work.. im Attaching a HBITMAP to CBitmap and then using SetBitmapDimension like this:
///////////////////////////////////////
CBitmap bBmp;
bBmp.Attach(hBmp);
bBmp.SetBitmapDimension(20 , 40);
// A Picture Static Control
m_PicCtrl.SetBitmap(bBmp);
////////////////////////////////////////
but when i run the app , its shows all image in the control. so can u plz any one help me ..???
Thank you.
|
|
|
|
|
see there [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Every once in a while, when I shut our app down, one or both extension DLL's don't appear to unload. Is there a tool available that unloads errant DLLs?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
You mean the process is still running?
led mike
|
|
|
|
|
The process that loaded the DLLs is no longer running (according to task manager). However, when I go back to the compiler to make changes and recompile, I get linker errors saying it can't create the LIB for the DLL. The only way to get around that is to reboot.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I'd use this[^] tool to tell which process has the files locked. Once you know that it will be clearer how to proceed.
Steve
|
|
|
|
|
John Simmons / outlaw programmer wrote: The process that loaded the DLLs is no longer running (according to task manager).
Then there must be another process that has it open then since yours is no longer running.
led mike
|
|
|
|
|
Hi there! I´m trying to code an expression evaluator that can be used as an XLL by Excel.
I used the code provided by an article on this site that explains how to make an XLL for interpolation. The whole solution compiles but when I try to add it using Tools->AddIns, a message ops up saying it is an invalid XLL. I think the problem is with my two functions here:
/*
** Expr_EvalX( expression )
**
** The Expr_Val function evaluates an arithmetic expression passed as an argument
** using infix notation, calculating it using Reverse Polish Notation.
** Arguments:
**
** LPXLOPER ... expression String to be evaluated as an expression.
**
** Returns:
**
** LPXLOPER Expr_Eval The result of the evaluated expression. Is equal to
** #VALUE! if result could not be determined (meaning there
** was some freaky error).
*/
__declspec(dllexport) LPXLOPER Expr_EvalX( LPSTR expression )
{
static XLOPER tempXLOper; // Return Data
tempXLOper.xltype = xltypeStr;
tempXLOper.val.str = expression;
return Expr_Eval( (LPXLOPER)&tempXLOper );
}
__declspec(dllexport) LPXLOPER Expr_Eval( LPXLOPER expression )
{
static XLOPER result;
XLOPER buff;
std::string str( (char*)(*expression).val.str );
double exprVal = 0;
int error = 0;
error = ExpressionEvaluator :: calculateDouble( str, exprVal);
buff.val.num = exprVal;
if ( xlretUncalced ==
Excel4( xlCoerce, (LPXLOPER)&result, 1, (LPXLOPER)&buff ) )
{
return 0;
}
// if the "error" variable was set above, something significant failed
// and we should return an error for all x targets
if ( error != 0 )
{
result.xltype = xltypeErr;
result.val.err = error;
return (LPXLOPER)&result;
}
return (LPXLOPER)&result;
}
They are the ones that should work as InterpX and Interp of that article´s XLL.
Could somebody help? Or point me to good articles on the subject.
Thanks!
|
|
|
|
|
template < class type >
class binarytree
{
public:
struct treenode
{
int element;
treenode *left, *right;
treenode() : left(0), right(0) {}
treenode(int item, treenode *leftnode=0, treenode *rightnode=0):element(item), left(leftnode), right(rightnode){}
};
protected:
treenode *root;
BOOL insert(treenode *&tree, const type& item);
....
};
template < class type >
BOOL binarytree<type>::insert(treenode* &tree, const type& item)
{
if ( tree==0 )
{
tree=new treenode(item);
return tree ? TRUE : FALSE;
}
else if (item < tree->element )
return insert(tree->left, item);
else
return insert (tree->right, item);
}
what is thing "BOOL" in this code ?? how can a function return TRUE, FALSE or a node of type treenode at same time. If anyone can clear me this thing BOOL, FALSE, TRUE .. I'l b thankful ...
-- modified at 13:18 Thursday 7th December, 2006
|
|
|
|
|
Pimra wrote: what is thing "BOOL" in this code ??
It's the type that's returned from the insert() method. It usually evaluates to 0 and 1.
Pimra wrote: how can a function return...a node of type treenode at same time.
It's not.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|