|
Hello Friends,
I am using the Win32 Application. In this project I am using EM_GETSELTEXT to get the selected Text From Rich Edit Control.
RichEdit Control is in another window. I have retrived its handle through FindWindowEx() Function.
But When I use the Following code it doesn't retrive the selected text
WCHAR SText[100]={};
lr = SendMessage(hChild,EM_GETSELTEXT ,(WPARAM)0,(LPARAM)SText);
if(lr <0)
{
dError = GetLastError();
}
lr shows the Number of charcter selected. But the SText(STEXT="") is empty after SendMessage.
|
|
|
|
|
Gaurang, I completely agree with you. It returns the length but not the value.
|
|
|
|
|
But why ??? do u have any Idea. ?? or is there any other way I can got the Selected text. WM_GETTEXT and WM_SETTEXT working fine.
|
|
|
|
|
GauranG033But When I use the Following code it doesn't retrive the selected text
It fails as a result of Unicode being used. You'll find that if you use ANSI, EM_GETSELTEXT would work as expected. Is that a viable option?
If not, use this:
char sz[100] = {'\0'};
LPWSTR SText;
LRESULT lr = SendMessage(hChild, EM_GETSELTEXT, 0, (LPARAM) sz);
USES_CONVERSION;
SText = A2W(sz);
Notice your text that I quoted above is not formatted correctly.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I tried you code. But still facing the same problem. Empty String.
is there any other way I can get the selected Text By user.
I have tried it in MFC application Like this
CWnd *hParent = FindWindow(_T("TfrmChat"),0);
CWnd *hChild = FindWindowEx(hParent->m_hWnd,0,_T("TPanel"),0);
hParent = FindWindowEx(hParent->m_hWnd,hChild->m_hWnd,_T("TPanel"),0);
hChild = FindWindowEx(hParent->m_hWnd,0,_T("TExRichEdit"),0);
char sz[100] = {'\0'};
LPWSTR SText;
LRESULT lr;
lr = hChild->SendMessage(EM_GETSELTEXT, 0, (LPARAM) sz);
USES_CONVERSION;
SText = A2W(sz);
|
|
|
|
|
GauranG033Empty String.
How are you verifying this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello, guyz.
In my current project I want to convert a tiff file(*.tif) to a bitmap file(*.bmp) but I don't know how to do it.
Do you have any idea on how will I able to do it or knew a thread or post with this topic?
Hope you can help me with this.
Thank you.
|
|
|
|
|
An easy way is to select a CBitmap in a DC and draw the tiff. Or I know the CXImage class here at CP.
Greetings from Germany
|
|
|
|
|
Thank you for your time KarstenK.
Can you please state more in details, because i'm just starting in C++.
Best regards
|
|
|
|
|
Then you got to learn a lot and be patient "Rom wasnt build on a day".
Conversion of graphics is an interface problem: you need to transport the data from the source to a (temporary) format which the target format can understand.
I strongly advice you to download and step trough this really good project: http://www.codeproject.com/bitmap/cximage.asp[^]
If you really like graphic conversion you will agree that this one is outstanding:
http://www.codeproject.com/bitmap/extendedbitmap2.asp[^]
This will take you some hours, cups of coffee and some headaches if you are really engaged. But it is worth it.
Greetings from Germany
|
|
|
|
|
Writing a robust TIFF file loader is a big project.
If you can use GDI+, it can save alot of work.
There's also the ATL CImage class, which uses GDI+ for loading and saving image files.
With CImage, you could do it in a few lines of code:
#include <atlimage.h>
...
CImage image;
image.Load(_T("C:\\TIFFFile.tif"));
image.Save(_T("C:\\BMPFile.bmp"), Gdiplus::ImageFormatBMP); Note that BMP files have a limited set of supported image formats. See
the documentation for the BITMAPINFOHEADER struct for details.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
I have simple excel sheet in which i have 2 columns 1)employee name 2) employee id. All the columns having values is in sheet1. Now, my problem is i want to read my excel using code. i don't know how to do it. There are various articles using odbc but i don't want to use odbc. Can nybody tell me how to do it....
Thanks in advance.
|
|
|
|
|
make it via COM: create a excel object and read the data.
Greetings from Germany
|
|
|
|
|
can you guide me more on this...
|
|
|
|
|
Look for the search box (at top of the side) and enter "excel and com" or "excel and automation".
If it is to challenging for you, you should consider doing the stuff via a csv-File.
Greetings from Germany
|
|
|
|
|
Using this code you can get the values from xl sheet in the variant variable var.
There are step to use this code: -
1. write the import statements acording to the verision of office u have
for office 2000 they are: -
<br />
#import "Lib\mso9.dll" no_namespace rename("DocumentProperties", "DocumentPropertiesXL") <br />
<br />
#import "Lib\vbe6ext.olb" no_namespace<br />
<br />
#import "Lib\Excel9.olb" \<br />
rename( "DialogBox", "ExcelDialogBox" ) \<br />
rename( "RGB", "ExcelRGB" ) \<br />
rename( "CopyFile", "ExcelCopyFile" ) \<br />
rename( "ReplaceText", "ExcelReplaceText" ) \<br />
rename_namespace("EXL")<br />
Best place to add these statements is in stdafx.h
2.Declare these variables: -
<br />
EXL::_ApplicationPtr pEXLApp;<br />
WorkbooksPtr pEXLBooks;<br />
_WorkbookPtr pEXLBook;<br />
WorksheetsPtr pEXLSheets;<br />
_WorksheetPtr pEXLSheet;<br />
3.
<br />
::CoInitialize(NULL);<br />
try<br />
{<br />
if(NULL == pEXLApp)<br />
hResApp = pEXLApp.CreateInstance("Excel.Application");<br />
else<br />
hResApp = pEXLApp.GetActiveObject("Excel.Application");<br />
<br />
pEXLBooks = pEXLApp->GetWorkbooks();<br />
pEXLBook = pEXLBooks->Open(_bstr_t("Path of the xls file"));<br />
pEXLSheet = pEXLBook->GetActiveSheet();<br />
<br />
_variant_t var = pEXLSheet->GetRange("A1")->GetFormulaR1C1();<br />
<br />
pEXLApp->GetActiveWindow()->Close();<br />
}<br />
catch(_com_error &e)<br />
{<br />
string strError;<br />
_bstr_t bstrSource(e.Source());<br />
_bstr_t bstrDescription(e.Description());<br />
_bstr_t bstrError(e.Error());<br />
<br />
_bstr_t err_msg = "Error : " + bstrError + "\nDescription : " + bstrDescription + "\nSource : " + bstrSource;<br />
<br />
strError = _com_util::ConvertBSTRToString(err_msg);<br />
AfxMessageBox(strError.c_str());<br />
}
Regards,
Pankaj Sachdeva
"There is no future lies in any job"
"but"
"future lies in the person who holds the job"
|
|
|
|
|
I want to convert char[] string to UTF-8.
How should I use int MultiByteToWideChar() and WideCharToMultiByte() to do such convertion?
And if I should not use the two function to resolve such task,but how should I do?
Thanks.
GOOD LUCK
|
|
|
|
|
First use MultiByteToWideChar() to convert the char string from your local code page to wide char, then use WideCharToMultiByte() to convert the wide char string to UTF8. You may use CP_ACP for your local code page, and code page for utf-8 is 1200.
But I've never tried the conversion between wide char and utf-8, so I'm not sure whether it would succeed.
|
|
|
|
|
I also do not want to convert the string to UTF-8.But I use the "libipod"(a opensource code of iPod),it use utf-8 and utf-16!
|
|
|
|
|
it is good style to use the API-functions, because they do really a good job in checking different parameters and conditions.
But they are hungry for parameters.
Greetings from Germany
|
|
|
|
|
Hi all,
How can set the max length of a combo box to 50 charcters only
Thanks in Advance
Dana
|
|
|
|
|
|
From the MSDN Help:
CComboBox::LimitText
BOOL LimitText( int nMaxChars );
Return Value
Nonzero if successful. If called for a combo box with the style CBS_DROPDOWNLIST or for a combo box without an edit control, the return value is CB_ERR.
Parameters
nMaxChars
Specifies the length (in bytes) of the text that the user can enter. If this parameter is 0, the text length is set to 65,535 bytes.
Remarks
Limits the length in bytes of the text that the user can enter into the edit control of a combo box.
If the combo box does not have the style CBS_AUTOHSCROLL, setting the text limit to be larger than the size of the edit control will have no effect.
LimitText only limits the text the user can enter. It has no effect on any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control when a string in the list box is selected.
Hope it helps
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Thanks all,
I am new to VC++.Trying to set that property but not able to do so.
Dana
|
|
|
|
|
hi,
in advance thanks to look my problem,
i am executing pushsource program which is in platform sdk. i am getting some errors while linking. i dont know what to do i have already included strmbasd.lib in the project library and the path is also set.
can any one help me how to get rid of this errors.
the following errors i am getting.
Linking...
LINK : fatal error LNK1221: a subsystem can't be inferred and must be defined
PushSource - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
can any one help me how to solve it.
amiya kumar das
|
|
|
|