|
Use CRichEditCtrl::StreamOut() and write your own stream callback function, in that you copy raw bits from rich edit control to HGLOBAL .
See the EDITSTREAM and CRichEditCtrl documentation for details.
Robert-Antonio
|
|
|
|
|
thanks alot brother..you solved the problem almost 95 %
Regards
Muhammad Ahmed
ahmed
|
|
|
|
|
the callback function is called, passing the data in segments, so should i allocate memory on the heap for each call and the integrate the whole data in a newly allocated memory or is there a way to keep appending data to the buffer allocated only once....(or is there a way to find in advance how much buffer we should have?)
thanks
ahmed
|
|
|
|
|
The callback function takes the cb parameter, which contains required size of CRichEditCtrl data. You can grow the HGLOBAL memory with GlobalRealloc .
Robert-Antonio
|
|
|
|
|
hello every body
I want to know how can i end an sdi application like what we do in the Dialog application by calling CDialog::OnOk()
Best Regards ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
I believe the best practice is to post a WM_CLOSE message to your CFrameWnd-derived object. Something like that: AfxGetMainWnd()->SendMessage(WM_CLOSE);
|
|
|
|
|
thank u for it is working now
Best Regards ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Hi!
I want in my program to be able to input text into an edit control and instead of having to move the mouse and click on the button to get the text input, I want it so that when you press enter, rather than closing the dialog, it will work the same as clicking on the button.
Can someone please help?
Thankyou
Ashman
|
|
|
|
|
I have done this some time ago. I don't know exactly how I have done it anymore, but I think I have used CWnd::PreTranslateMessage. If you overload it in your dialog class you can capture the key event before it is sent to the window!
|
|
|
|
|
Hi
I think to deactivate Enter Key u have to cancel OnOk() in the virtual member function like the following:
//////////////////////////////////////////////
void CanyDlg::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
//////////////////////////////////////////////
Best Regards ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Capture the WM_COMMAND message for your default button (lets say here your default button has the ID IDOK) by overriding the relavant function, CYourDialog::OnOk in this case, then rather than calling the base CDialog::OnOk, move the focus to your edit control, either like this:
GetDlgItem(IDC_MY_EDIT_CTRL)->SetFocus();
Or like this:
SendMessage(WM_NEXTDLGCTL, (WPARAM)GetDlgItem(IDC_MY_EDIT_CTRL)->GetSafeHWnd(), TRUE);
The difference between them is the second is usually more suited to moving the keyboard focus around a dialog box as it updats the button borders correctly, so in full:
void CMyDialog:::OnOk()
{
if(CWnd::GetFocus() == GetDlgItem(IDC_MY_EDIT_CTRL))
{
// edit control focused, so do normal stuff
CDialog::OnOk();
}
else
{
// move focus to edit control
SendMessage(WM_NEXTDLGCTL, (WPARAM)GetDlgItem(IDC_MY_EDIT_CTRL)->GetSafeHWnd(), TRUE);
}
}
This will make enter move the focus to the edit control if something other than the edit control is foucsed, or make enter behave as normal if it is the edit control that's focused
|
|
|
|
|
That's all U need in MFC. I know very similar solution in win32sdk. If U need tell?
Cheers!
Siddharth
|
|
|
|
|
hi Ashman,
all you have to do is to set the focus on the specific control... you can use
(CEdit*)GetDlgItem(YOUR_Edit_ID))->SetFocus(); to avoid you to move explicitly your mouse upon the EditBox, and in the OnInitDialog() , you tell which button to be pressed when the user presses Enter key by giving it the property Default
TOXCCT
|
|
|
|
|
I want to initialize a executable, making OS to search for the file.
STARTUPINFO si = {sizeof(si)};<br />
PROCESS_INFORMATION pi;<br />
TCHAR szCommandLine[1024] = {0},*pszCommandLine = 0;<br />
<br />
DWORD lFileName = <br />
SearchPath(NULL,(LPCWSTR)"YPager",(LPCWSTR)".exe",(DWORD)sizeof(szCommandLine), szCommandLine, *pszCommandLine);<br />
<br />
BOOL bCreate = CreateProcessNULL,szCommandLine,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
there is no complier error but szCommandLine cannot fill the path.
Any other suggestions to achieve the same goal is appreciated.
Cheers!
Siddharth
|
|
|
|
|
It will not help you to get a response faster!
|
|
|
|
|
There was a bit problem with my server. Hence it's like that. Any way sorry if anyone get anoyed
|
|
|
|
|
Hi,
I use VC6 (SP5) in Windows XP Pro (SP1). I wanted to add Greek/Chinese strings. I edited the .rc files in a Unicode editor, saved the file as UTF-8. But, now, VC6 has problems handling the file. But, if I save it as a normal file, the strings are garbled.
How do I add other language strings to my resource file and what shd I use to compile it?
TIA
MRK
|
|
|
|
|
I've noticed that VC6 has problems in dealing with language strings, especially unicode characters. What we do normally is create the structure of the resource file using the VC resource editor, then have the translators to use their text editor (I think they use TextPad), re-include the modified resource file in Visual Studio. DO NOT modifiy in any way the file after it has been translated - do not change dialogs, not accelerators, nothing. If you do get a saved copy of the translated version and copy and paste the text using a text editor to replace the garbled text.
VC7 seems to have addressed the problem.
Hope that helps.
|
|
|
|
|
I want to make a wizard. For example i have four dialogs. The last one is my main dialog.
Now i open the first dlg. From this dlg i want to open the next dlg with a button, but the first one doesn´t close.
How can i check if the second dlg is opened and i´m able to close the first one.
maybe there is another way to create a wizard!?
J.J.
|
|
|
|
|
|
|
I have source code for a DLL created in C++ .net, I want to debug this.
I have created a second project (console application ) in the same solution ,for calling a particular function from the first project and passing parameter to it.
But when I tried to call that function
int DNAPrintExport InstallPrinter(const char* cpstrPrinterData)
{
}
using the following code in the second project
int abc=InstallPrinter("Hello");
I am getting error C2065: 'InstallPrinter' : undeclared identifier
Can anybody help me to do this please
Thanks in advance
Jayakrishnan
|
|
|
|
|
Have a look here[^] and see how _declspec(dllimport) is used to import a function from a DLL to another application.
|
|
|
|
|
Dear all,
I am using Visual C MFC Dialog-based application to obtain USB data from a Cypress chip. DeviceIoControl(IOCTL_EZUSB_BULK_READ...)... I am doing this using multithreading method. However, I face a problem when I compile. This is part of my program:
UINT SendOpThread(LPVOID pParam)
{
int bResult;
CThreadInfo* pTh = (CThreadInfo*)pParam;
BULK_TRANSFER_CONTROL2 btc;
btc.pipeNum = 0;
DeviceHandle = CreateFile("\\\\.\\ezusb-0",
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
bResult = DeviceIoControl (DeviceHandle,
IOCTL_EZUSB_BULK_READ,
&btc,
sizeof (BULK_TRANSFER_CONTROL),
r_Buffer,
sizeof(r_Buffer),
&nBytes,
NULL);
CloseHandle(DeviceHandle);
wsprintf(str, "r_Buffer[%d]: %04X\n", i,r_Buffer[i]);
SendDlgItemMessage(IDC_OUTPUT6,
LB_ADDSTRING,
0,
(LPARAM)(LPCTSTR) str);
return(bResult);
}
void CUSB1Dlg::OnBulkRead()
{
// TODO: Add your control notification handler code here
int Code=1;
stream1 = fopen("data.txt","a+") ;
myWinThread = AfxBeginThread(SendOpThread, &Code, THREAD_PRIORITY_HIGHEST,0,CREATE_SUSPENDED);
myWinThread->m_bAutoDelete=FALSE;
myWinThread->ResumeThread();
.
.
.
}
When I compile, I got this error:
'SendDlgItemMessageA' : Function does not take 4 parameters
I found from the Help:
SendDlgItemMessage consists of 3 types: which is CWnd, CWindow, & Windows User Interface. Which 1 should the thread belongs to?
I assumed that it belongs to WUI, and so it requires HWND hDlg, a handle of dialog box. Since I am using Dialog-based application where the dialog is already created, how should I put for the hdlg parameter?
I really wish that someone could help me...
Einly
|
|
|
|
|
OK, here's my 2 cents worth. You can change the code slightly by using
CWnd* pWnd = GetDlgItem(IDC_OUTPUT6);
if (pWnd)
{
pWnd->SendMessage(LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)str);
}
assuming, of course, this happens in a dialog member function.
If not, and it's in something like a worker thread, as part of the thread parameter block, you need something more complex than a simple int.
Perhaps
struct paramblock {
int code;
HWND hWnd;
};
would help
Then get the HWND before invoking the AfxBeginThread, and use the WINAPI version.
As a rule, you can specify you want that version by using the global scope prefix '::'
eg ::SendMessage(param.hWnd, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)str);
Hope this helps
Steve S
|
|
|
|
|