|
ca you show a piece of the code around, + the exact error message/code please ?
also, what version of MFC do you use ?
|
|
|
|
|
On my env (Visual Studio 6), I can find the macro defined in windowsx.h header.
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.
|
|
|
|
|
Hallo,
I have a thread that use object , when I end the thread the object used into the thread do not call the destructor and the let me some leak !
Why the object m_OPCServer & m_OPCStock are not destructed when I stop the thread ?
What can I change into my code that those object will be destructed!
The code:
CWinThread* newthread=NULL;
stop=false;
newthread=AfxBeginThread(ThreadAddOpcServer,LPVOID(&stop),THREAD_PRIORITY_BELOW_NORMAL ,0,CREATE_SUSPENDED );
newthread->ResumeThread();
UINT ThreadAddOpcServer(LPVOID nparam)
{
bool* sstop=static_cast<bool*>(nparam);
static int i=10;
OPCServer m_OPCServer;
StockIOWINCC m_OPCStock(&m_OPCServer);
double movevalue=0;
while(!*sstop) {
m_OPCStock.ChangeStatus("INTERN\\test_opc2",movevalue++);
m_OPCStock.ChangeStatus("INTERN\\test_opc1",10*movevalue);
}
AfxEndThread(0,true);
return 0;
}
Thank for help
AutreChien
|
|
|
|
|
First, when you post code, please use the 'code' tag above the emoticons, it will make your code much more readable.
Second point: why using AfxEndThread ? Your function is finished so your thread will exit. Thus why calling AfxEndThread ?
Third point: you have a loop which check for a flag. But are you setting this flag to false in another thread ? If yes, how are you doing that ? Can you post some code ?
|
|
|
|
|
Cedric Moonen wrote: First, when you post code, please use the 'code' tag above the emoticons
no Cedric, he should use the 'pre' tag ! lol
|
|
|
|
|
Yes I set from button click the variable stop (global variable) as true
void CTestOPCServerDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
stop=true;
OnOK();
}
Thank you for your help!
AutreChien
|
|
|
|
|
I strongly advise you to read Joe Newcomer's article on how to use worker threads to understand how they are supposed to be used and to avoid common pitfalls regarding multithreading.
You'll find it here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
Hi everybody,
i have a problem with fullpath file names containing back slashes. The file names are saved in a CString array. The problem are the singel back slashes for ex.
"C:\dir1\dir2\file.txt". Is there an easy way to substitute each "\" with "\\"?
Thanks in advance
|
|
|
|
|
im79 wrote: Is there an easy way to substitute each "\" with "\\"?
CString::Replace()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
CString has the Replace method, but \ must be properly escaped, for instance:
str.Replace("\\","\\\\")
Sure do you need this?
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.
|
|
|
|
|
don't !!!
'\\' is only the representation in "design mode" (when coding) of the character \ .
when you type a path in windows explorer, you type with a single \ , don't you ?
|
|
|
|
|
im79 wrote: Is there an easy way to substitute each "\" with "\\"?
why you need that?
"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
|
|
|
|
|
Hi,
i need the pathname to open the file. I get the filenames list form a CFileDialoge object. I found some examples in MSDN while reading about CFile where the pathnames have double back slashes. So i think i have to change the back slashes into double backslashes
|
|
|
|
|
i repeat : No !
paths are written with double backslashes only when in a string in your source code only, like
<code>"</code>C:\\myfolder\\myfile.txt<code>"</code>
but this produces a paths to being like this internally :
C:<code>\</code>myfolder<code>\</code>myfile.txt
if you get a string from a CFileDialog for instance, you don't need to modify the path at all...!
|
|
|
|
|
Hi toxcct, hi everybody,
i' get the pathname CString with CFileDialog and then i pass it to function casts the CString to char* then it opens the file with fopenf. The C function fopenf is used because of a legacy code with a lot of fscanf calls with a specific foramt.
I'm forecd to use theh old code for many reasons. Now, the orignal code workes with double backslashes, and if don't change the single backslashes to double, it won't work. Now i'm more confused
Is there a difference when useing CFile::open() instead? In that case i need to rewrite the whole fscanf block
Thank u all for u help
|
|
|
|
|
damn, don't you understand ???????
well, i sum up, but it's my last explanation !
1. you choose your file with the CFileDialog
2. you then get the file path into a CString object
3. you pass this CString object directly to fopen() !
there's no need to change a backslash into double backslashes, because you need this only when you hardcode strings in your source code (because the \ is the character escapment, and '\\' is the ascii code for the \ character) !!!
|
|
|
|
|
If you can help the man, do so. WHY he wants to do it is not important at all.
"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
|
|
|
|
|
helping a guy doesn't always provide a working piece of code !
in this case, what the OP needed is useless, simply he didn't understand that double backslashes exists only because the backslash is the escapment character...
i think what Alok did was to make the OP explicit his real need, and then Alok could explain him that he was wrong...
|
|
|
|
|
Helping someone doesn't necessarily include providing a piece of working code. Asking why someone wants to do something is irrelevant. If someone can't actually help, they should just STFU and let someone else step up. The post I responded too has already generated three needless replies and just makes noise that the OP has to wade through.
"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
|
|
|
|
|
John Simmons / outlaw programmer wrote: If you can help the man, do so. WHY he wants to do it is not important at all.
Sir, actually just want to know root cause of the problem.. numerous times people here at forums ask thing which they don't actually need! which create problem to them at later stage.. so to solve there problem.. some time people ask what actually they need.. Just like we do in URS/SRS phase.. You very well know that.
secondly, if you see.. that guy require double slashes which you see he don't need! hope i clear my point.. if any thing wrong... i am sorry!
"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
|
|
|
|
|
Hi All,
On what all events CWnd::OnKillFocus event is generated.
Actually, I have my grid and when I copy & paste a value in the cell, OnKillFocus event gets generated. I have actally confused with this behavior.
Is anyone have some idea about the same?
Thanks
Suraj Gupta
|
|
|
|
|
A kill focus notification should only be sent when a control actually looses focus. For example, if you have a button control focused, and you press <tab>, use a nmemonic to go to another control, or click on another control/window, that button should send a kill focus message.
Pasting into an edit control, or some other editor, should not be sending kill focus events, IMHO. You may get them as you moved from the copied cell to the target cell (because the source of the copy looses focus), and this may or may not be correct behavior depending on the behavior of the grid.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
hi all,
i am having Two DLL's and in one Dll i am having a Class, in that Class i am having a static member variable.
Now in another DLL's Class i want to acess the One's (First Dll's) static member variable.
//----------------------------------------------------------
First DLL,
Class One
{
static int onevar;
}
//----------------------------------------------------------
my question is in the second Dll
Class Two
{
// I want to dynamically link only the First Member Variable.
}
Please give any code such that i can access the First DLL static Member Variable in the Second DLL.
Any Import Techinique.
Uday kiran
|
|
|
|
|
example
#define TESTDLL_API __declspec(dllexport)
//Testdll.h
class TESTDLL_API CTestDLL {<br />
public:<br />
CTestDLL(void);<br />
static int m_i;<br />
};
//Testdll.cpp
TESTDLL_API int CTestDLL::m_i=0;
In DLL two, where you are going to use this header file and
define TESTDLL_API macro as __declspec(dllimport)....
Hope this helps..
Thanks...
Please let me know if you have some doubt....
Suraj Gupta
|
|
|
|
|
I have encountered annoying problem:
<br />
template <class Type, class Allocator>} class A : public B, public vector<Type,Allocator><br />
{<br />
}<br />
<br />
class sample1 : public mybase<br />
{<br />
}<br />
I have a need to cast this template:
<br />
A<sample1*> vec;<br />
vector<mybase*> *result = (vector<mybase*>*)&vec;
How to do it if it is actually possible?
(i need exactly that situation, from A template i need to get pointer to A but casted to vector)
Thank you for reading this and even more for the answer... although i am afraid it is not posssible
|
|
|
|