|
1) do you know the exact structure of the file content ? is it text or binary ? how are shaped the internal elements ?
2) what have you already tried ?
3) what's the problem with the previous answers[^] you got ?
couldn't you just follow the same thread ?
|
|
|
|
|
No, this is not possible directlt. You will need to read your file in memory (for example in a string) and insert the data there. Then you will need to write everything to the file again.
|
|
|
|
|
i want to know about the tcp flow in network simulator so that i could make changes in desired place.
One more thing after change in code of network simulator each time we have to configure it then install it or there's some other way out.
please reply me soon...
Please reply me soon.......n u can ask me any questions in c/c++/.net
|
|
|
|
|
chandni chi wrote:
Please reply me soon.......n u
i can't understand your requirement.. could you tell us that in bulleted point.. that may be much easier
"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
|
|
|
|
|
Hie All,
I have created a thread which calls a function. Sometime this function may get hung. In such situation I need to termintate my thread gracefully. Is there any good solution exists?
Note: the function is from third party library, I can not change or control it.
|
|
|
|
|
vikrams wrote: I have created a thread which calls a function. Sometime this function may get hung. In such situation I need to termintate my thread gracefully.
If your thread hangs you've passed the point of ending the thread gracefully since you cannot communicate with it. Are you sure that this third-party-lib is thread safe and doesn't produce deadlocks if called from different threads? If it is thread safe it would probably say so in its documentation.
Try a single threaded solution and see if it works.
You're not using COM, are you?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Third party lib is thread safe. here this function hangs bcoz of some long time taking operation in rare cases. And we don't want to wait for that operation ...
|
|
|
|
|
vikrams wrote: this function hangs bcoz of some long time taking operation in rare cases. And we don't want to wait for that operation
Sounds like a dangerous situation. There's only one way to end the thread and that's to call ::TerminateThread() , but that's not really recommended. See here[^] for reasons why.
No possibility for setting a timeout on the lengthy operation?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Yes. We do not have any timeout setting on that operation
and I want to prevent terminateThread
|
|
|
|
|
vikrams wrote: We do not have any timeout setting on that operation
If you can not end the function of the 3rd party lib, gracefully ending your thread would not help anyway, as the lib would still continue working (and not release any resources).
So, there is a gap in the API of said lib, effectivly rendering it incompatible with threading.
Can you simulate that call usind other, smaller calls to the library?
You could start another process with your lib and call that. Terminating a process is guaranteed to release all resources aquired by that process - the OS sees to that.
Failure is not an option - it's built right in.
|
|
|
|
|
Hi !!!
Can any body know about to display string message ??
I know some of the method like..
1.acutpritnf("Inser point");
2.Cstring mystr;
mystr.load (IDS_MYBLOCK)
Any other trick or method do u know for displaying string message..
Thanking you.
|
|
|
|
|
Shah Satish wrote: mystr.load (IDS_MYBLOCK)
are you talking about displaying, or loading ?
what you do here is getting the string in the resource table and put it into your CString object.
you don't display it at all.
where do you want to display ? console ? static ? any control ? messagebox ?
please be clear when you ask a question
|
|
|
|
|
I want to display message on Autocad Prompt..Same as Acutprintf () function but here i have one string (IDS_MYBLOCK = Insert point )and i want to display this string on Autocad Prompt..
|
|
|
|
|
i don't know acutprintf(), but why not just trying this :
acutpritnf("Inser point");
Cstring mystr;
mystr.load (IDS_MYBLOCK);
acutprintf(mystr);
acutprintf("%s", mystr);
|
|
|
|
|
Using the DrawString function in GDI+ to render automatically wrapped text into a given rectangle, how do I indent the first line by a specific number of pixels?
|
|
|
|
|
i'm trying to build an ActiveX using MFC to control a device,
i got some problem when i tried to get the WM_USER message that send by the device,
i tried this code
LRESULT CALLBACK AfxWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
CWnd* pWnd = CDialog::FromHandlePermanent(hWnd);
return AfxCallWndProc(pWnd, hWnd, nMsg, wParam, lParam);
}
LRESULT AFXAPI
AfxCallWndProc(CWnd* pWnd, HWND hWnd, UINT nMsg,
WPARAM wParam = 0, LPARAM lParam = 0)
{
LRESULT lResult;
lResult = pWnd->WindowProc(nMsg, wParam, lParam);
return lResult;
}
LRESULT CCertDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{ //CDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
LRESULT lResult = 0;
if (!OnWndMsg(message, wParam, lParam, & lResult))
lResult = DefWindowProc(message, wParam, lParam);
return lResult;
}
BOOL CCertDlg::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{ //CDialog::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
if (message == WM_USER+0)
return_pin(hwnd);
else if(message == WM_USER+1)
return_track2(hwnd);
//OnNotify(wParam, lParam, & lResult);
//else
//... // msg map related
return true;
}
LRESULT CCertDlg::DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
{ //CDialog::DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
if (m_pfnSuper != NULL)
return ::CallWindowProc(m_pfnSuper, m_hWnd, nMsg, wParam, lParam);
}
but its return error 2447 : missing function header (old-style formal list?) in afxwndproc function, can anybody help me?
its there any recomendation, another way to get the window message using mfc in C++?
thx
|
|
|
|
|
|
Try removing the default args of 0 from AfxCallWndProc.
|
|
|
|
|
I am doing the following things for neighbour child window updation in win32.
child window which contain listview control.
<code>
if(((LPNMHDR)lParam)->code == NM_CLICK)
{
iSelect=SendMessage(hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED);
if(iSelect==-1)
{
break;
}
index=iSelect;
ShowWindow(hWndinoutfiledir,SW_HIDE);
ShowWindow(hwndEncrypt,SW_HIDE);
ShowWindow(hwndSplit,SW_HIDE);
ShowWindow(hwndUpload,SW_HIDE);
ShowWindow(hwndTagEditorDlg ,SW_SHOW);
<big>::SendMessage(hwndTagEditorDlg ,IDC_HIDDEN_BTN,0,0);
</big>
UpdateWindow(hwndTagEditorDlg);
}
</code>
after click this below code is for updating child window. But it doesn't work.
LRESULT CALLBACK TagEditorProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
Utility util;
switch(message)
{
case WM_INITDIALOG:
if(_ProtectSet[index].listviewIndex==index)
{
SetDlgItemText(hDlg,IDC_EDIT_ARTIST,util.ConvertStringToWCHAR(_ProtectSet[index].artist));
SetDlgItemText(hDlg,IDC_EDIT_ALBUM,util.ConvertStringToWCHAR(_ProtectSet[index].album));
SetDlgItemText(hDlg,IDC_EDIT_YEAR,util.ConvertStringToWCHAR(_ProtectSet[index].year));
SetDlgItemText(hDlg,IDC_EDIT_COPYRIGHT,util.ConvertStringToWCHAR(_ProtectSet[index].copyright));
SetDlgItemText(hDlg,IDC_EDIT_AUTHOR,util.ConvertStringToWCHAR(_ProtectSet[index].author));
SetDlgItemText(hDlg,IDC_EDIT_GENRE,util.ConvertStringToWCHAR(_ProtectSet[index].genre));
SetDlgItemText(hDlg,IDC_EDIT_DESCRIPTION,util.ConvertStringToWCHAR(_ProtectSet[index].desc));
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_SAVE_TAG:
_ResideId3TagForSelectedFile(hDlg);
MessageBox(hDlg,_T("You file has been saved"),_T("encoder"),0);
break;
<big>case IDC_HIDDEN_BTN:
MessageBox(0,_T("HAY"),_T("HI"), 0);
::PostMessage(hDlg,WM_INITDIALOG,0,0);
break;</big>
}
break;
}
return FALSE;
}
can any body help me how should update my child window with null control or assigne values from object.
|
|
|
|
|
amitmistry_petlad wrote:
::SendMessage(hwndTagEditorDlg ,IDC_HIDDEN_BTN,0,0);
problem is that. you are sending the Ctrl ID in the message Field and trying to get in WM_COMMAND message!
better way of sending it is
PostMessage(hwndTagEditorDlg,WM_COMMAND,IDC_HIDDEN_BTN,0); and capturing that in WM_COMMAND wParam Parameter
"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
|
|
|
|
|
A small clarification Alok:
you've omitted the notification code for the button which probably should be BN_CLICKED . The WPARAM parameter for the WM_COMMAND message contains both the control ID and the notification code. The code for simulating a user click on the IDC_HIDDEN_BTN should look like this:
::PostMessage( hwndTagEditorDlg, WM_COMMAND, MAKELONG( IDC_HIDDEN_BTN, BN_CLICKED ), NULL );
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: The code for simulating a user click on the IDC_HIDDEN_BTN should look like this:
offcourse.. you can also use SendDlgItemMessage!
"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
|
|
|
|
|
ThatsAlok wrote: u can also use SendDlgItemMessage
Very true, but that call chain will eventually call ::SendMessage() which is synchronous. Perhaps the idea was to have an asynchronous implementation.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: ery true, but that call chain will eventually call ::SendMessage() which is synchronous. Perhaps the idea was to have an asynchronous implementation.
you can make SendMessage Sync call Async by using ReplyMessage Api!
|
|
|
|
|
ThatsAlok wrote: you can make SendMessage Sync call Async by using ReplyMessage Api
Umm, not exactly...
It may be that we're talking about different levels of abstraction, but the call to ::SendMessage() always block until the message is "handled".
In a single threaded situation a call to ::SendMessage() would be similar to a function call, the message will never appear in the message queue. In this situation ::ReplyMessage() has no effect since it wouldnät make any sense.
When a thread sends a message to another thread with a call to ::SendMessage() , the sending thread will block until the receiving thread has handled the message. In this situation you may call ::ReplyMessage() to release the blocked thread before returning from the message handler in the receiving thread.
MSDN says: If the message was not sent through SendMessage or if the message was sent by the same thread, ReplyMessage has no effect.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|