|
Thanks a Lot
Regards
Abhishek.
|
|
|
|
|
Hi.
Is there a function to convert a text from a clipboard to its original form including individual lines? For example, let say you copy three lines of text and then paste it in Notepade. How does it know there texts' original format?
I have some ideas and one of which is to scan the character array and search for '/n' or "/r/n."
Thanks,
Kuphryn
|
|
|
|
|
That sounds like a good plan to me!
The data must be in a registered clipboard format, and CF_TEXT (or CF_UNICODETEXT) is probably the one to ask for. This gives you the raw character (or wide character data), and it will have embedded newline or carriage-return/newline pairs as they were placed in by the source of the cut or copy.
You could use a CString and the Find() member, or if not, then something like strchr, wcschr or for portability, _tcschr would help you find the line breaks. If you are happy to modify a copy of the data, strtok (_tcstok) would be easy enough.
Steve S
[This signature space for rent]
|
|
|
|
|
the process is
1. check clipboard format (text in ur case)
2. get the data
3. the data should be: line0\r\nline1\r\nline2 if 3 lines for nodepad
includeh10
|
|
|
|
|
Okay. Thanks everyone.
Kuphryn
|
|
|
|
|
in CDocument sub-class, i create a thread to access a buffer, at the CDocument closing time, sometimes a run-time happens. i don't know why.
coding as this:
class MyDoc: public CDocument
{
..................
//they are init as null in constructor
HANDLE hThread;
BOOL bLoop;
DWORD dwThreadID;
char*pBuf;
};
MyDoc:OnOpenDocument(...)
{
pBuf=new char [50000];
hThreat=CreateThread((LPSECURITY_ATTRIBUTES)0,0,
(LPTHREAD_START_ROUTINE)Proc_Thread,
this,0,&dwThreadID);
.........................
}
void MyDoc::OnCloseDocument()
{
bLoop=0;
if(hThread)CloseHandle(hThread);
if(dwThreadID)::PostThreadMessage(dwThreadID,WM_QUIT,0,0);
::WaitForSingleObject(hThread,(UINT)(-1));
delete []pBuf;
................................
}
int WINAPI Proc_Thread(void*pVoid)
{
MyDoc*p=(MyDoc*)pVoid;
char*pBuf=p->pBuf;
while(p->bLoop)
{
//access pBuf
}
return 1;
}
note: the only problem is at closing time.
is something wrong with the coding?
thx
includeh10
|
|
|
|
|
Post a message at the end of Proc_Thread() informing the primary thread that the worker thread has closed. That will help make synchronization smoother.
Kuphryn
|
|
|
|
|
Another alternative would be to WaitForSingleEvent on the thread handle in your UI thread, to guarantee that the worker thread has completed.
When the "primary" thread terminates, this usually calls ExitProcess at some stage, which kind of tears things from under the feet of other threads...
Steve S
[This signature space for rent]
|
|
|
|
|
but i can't find the function WaitForSingleEvent?
thx
|
|
|
|
|
Ah. That's because I meant to type WaitForSingleObject instead.
Sorry about that, it's early in the morning here, and I didn't get much sleep.
Steve S
[This signature space available for rent]
|
|
|
|
|
thx, it is 100% new for me, but what does post a message mean?
post what messge? inside or outside loop?
please give me more details.
thx
includeh10
|
|
|
|
|
Posting a message at the end of a thread will update your primary thread on the status of the worker thread. For example, the message could trigger the primary thread to display the updated data. Furthermore, you should always post a message so that the primary thread can call closehandle() to ensure the thread is closed.
Kuphryn
|
|
|
|
|
returning from your Proc_Thread procedure automatically destroys the thread, without needing to send it any other message. A normal Proc_Thread has an event/message loop of the form :
BOOL bContinue = TRUE;
while ( bContinue )
{
switch( ::WaitForSingleObject( m_hComponentReadyEvent, m_WaitTime) )
{
case WAIT_OBJECT_0:
if ( !m_bShouldStopNow )
{
}
break ;
case (WAIT_OBJECT_0 + 1):
MSG msg ;
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
bContinue = FALSE ;
break ;
}
TranslateMessage(&msg);
DispatchMessage(&msg) ;
}
break ;
case WAIT_TIMEOUT:
if (m_bShouldStopNow)
bContinue=FALSE;
break ;
default:
break;
}
}
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
I have a problem...
When I am add some 'defines' in the 'resource.h' file, like
#define ID_BAND 110
...
and after that I try to open the class wizard, the class wizard put an error on the screen: "Parsing error: afx Message... input string: "LPTSTR MakeString(UINT..."
I searched and found out, that the following section in the 'MainFm.h' file producing the error:
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
LPTSTR MakeString(UINT stringID);
LPTSTR m_ToolTipsTable[NUM_TOOL_TIPS];
DECLARE_MESSAGE_MAP()
Can anyone help me??? (I use embedded Visual C++ 3.0)
--
Nice greets, Daniel.
|
|
|
|
|
All you need to do is to move the declarations of MakeString and m_ToolTipsTable outside the //{{AFX_MSG(CMainFrame) and //}}AFX_MSG block, so just before or just after is fine. The ClassWizard parses the code inside that block (among others), and it isn't able to cope that well with arbitrary declarations.
Steve S
[This signature space is available for rent]
|
|
|
|
|
Thanks!!!
--
Nice greets, Daniel.
|
|
|
|
|
How can I change the bitmap of a button in a CommandBand?
The images are stored in a image list.
I use embedded Visual C++ 3.0 with WinCE 3.0.
--
Nice greets, Daniel.
|
|
|
|
|
Hi all, I'm trying to use ShellExecute API to send email, but got some problems, the biggest one is that I don't know how to add line breaks into the email body, below are my code:
::ShellExecute(NULL,
"open",
"mailto:abc@def.com?subject=hello&body=hi,\nHow are you?",
NULL,
NULL,
SW_HIDE);
Everything went OK except the line break got eaten, I also tried "\n\r", no good either. Anyone know how to add line breaks? Thanks in advance.
Bin
|
|
|
|
|
You're probably better off just using MAPI. Do a search for MAPI here, there are a few nice articles / wrapper classes.
|
|
|
|