|
Thanks for scrolling, but i need the first line to be displayed at the bottom of CEdit. Imagine empty Edit control. Then i call some AddLine(...) function and this line appears at the bottom (not at the top like CEDit does). The second line moves first one upward and so on.
Generally i need something like this
http://www.codeguru.com/controls/output_window.shtml
but with ability to select text
|
|
|
|
|
Derive CMyEdit from CEdit. Add this method to CMyEdit:
void CMyEdit::Insert(LPCTSTR lpszText)
{
SetSel(0, 0);
ReplaceSel(lpszText);
}
Add lines to edit box like this:
CMyEdit m_edit;
.
.
.
for (int n = 0; n < 100; n++)
{
CString str;
str.Format("This is line %d\r\n", n);
m_edit.Insert(str);
}
Note: in Resource Editor, make sure edit box has styles multiline, vertical scroll, and auto vscroll.
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
HPSI have done it.
May be, you need the first line is always visible.
void EnsureVisible()
{
// The pointer to my edit.
CMyEdit m_edit;
int nFirstVisible = m_edit.GetFirstVisibleLine();
// Scroll the edit control so that the first visible line
// is the last line of text.
if (nFirstVisible > 0)
{
m_edit.LineScroll(-nFirstVisible, 0);
}
}
Yes,Free Code project~~~~
|
|
|
|
|
hello,
I want to send a pointer from my VB client app. to a VC dll the code is :
for VB
-------
Private Declare Sub GenerateReport Lib "Generator.dll" (ByVal datele As ADODB.Recordset)
Private Sub Command1_Click()
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
c = "PROVIDER=sqloledb;server=romulus;uid=sa;pwd=951;DataBase=SindServLast"
Set con = New ADODB.Connection
con.Open c
Dim s As String
s = "select * from T_USR_Useri"
Set rs = con.Execute(s)
GenerateReport rs
End Sub
fot VC dll
-----------
void GenerateReport(_RecordsetPtr pRs)
{
pRs->MoveFirst();
CString text;
text=(char*)((_bstr_t)pRs->Fields->GetItem((_variant_t)("usr_LoginName"))->Value);
}
and everything works fine in vc ... the pointer is recived correctly and the text CString is filled ok but after that when my c++ function ends and the execution returns to VB the VB client crushes ... and raise an access violation error ..
why ?
thanks !!!!!
|
|
|
|
|
Perhaps you should be use "_RecordsetPtr* pRs".
Try it,then you could be success.
Yes,Free Code project~~~~
|
|
|
|
|
suncho wrote:
Perhaps you should be use "_RecordsetPtr* pRs".
I doubt it. _RecordsetPtr is a smart pointer. Nevertheless, he could try it. You have no idea how many times I am wrong.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
this is a way, yes, use a pointer's pointer.
In fact, i doubt it too, but should be try.
Yes,Free Code project~~~~
|
|
|
|
|
if I use _RecordsetPtr *pRs it will get me compiler errors ... _RecordsetPtr it is already a pointer ... and his sizeof is 4
|
|
|
|
|
Hi,
I would like to convert a hexadecimal value to decimal. is there any method in C++ available for me to do that??
For example :
The hexadecimal value of '5a' should be converted to 90 in decimal.
Thanks.
|
|
|
|
|
long lVal = 0x5a;
Yes,Free Code project~~~~
|
|
|
|
|
Given a hex value as a string representation, you could use
strtol or _tcstol to convert using a given base. In your case, this would be 16.
something like:
TCHAR czHex[] = _T("5a");<br />
TCHAR* pzStop = NULL;<br />
long nValue;<br><br />
nValue = _tcstol(czHex, &pzStop, 16);<br />
std::wcout<<_T("Hex Value: ")<<czHex<<_T(" equals: ")<<nValue<<std::endl;<br />
should to the trick. I'm sure there are other ways.
"..Even my comments have bugs!"
Inspired by Toni78
|
|
|
|
|
RChin wrote:
"..Even my comments have bugs!"
Inspired by Toni78
I had no idea that I inspired you! Thank you for noticing my signature.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
How I control the size of a window meta file when paste it?
example:
//write a WMF and put it into the clipboard.
void copy()
{
CMetaFileDC * m_pMetaDC = new CMetaFileDC();
CRect rc(0,0,20000,20000);
m_pMetaDC->CreateEnhanced(GetDC(),_T ("c:\\test.wmf"),&rc,"name");
//drawing the lines in the DC.....
HENHMETAFILE hMF= m_pMetaDC->CloseEnhanced();
//copy to the clipboard
OpenClipboard();
EmptyClipboard();
::SetClipboardData(CF_ENHMETAFILE,hMF);
CloseClipboard();
}
//then paste the file in a CRichEditView.
void CMyView::PasteIt()
{
GetRichEditCtrl()->Paste();
//clear the clipboard
OpenClipboard();
EmptyClipboard();
CloseClipboard();
}
In windows2000, I can control the size of the metafile with the third parameter of the function CreateEnhanced.But in Win98, the parameter have no function. Why? How control the size in win98?
Thanks a lot.
Yes,Free Code project~~~~
|
|
|
|
|
I have some bitmap buttons i edited thier images in the resource editor and im using the CBitmapButton::AutoLoad() member my problem is that the grey color the editor has doesnt match the grey color or buttons or windows is there a way to give it that windows grey look or does anyone know the exact rgb value of the windows default grey color?
|
|
|
|
|
I don't know the exact grey color of buttons but I can tell you this much. What you are looking for might not be the best solution. In Windows, the default colors can be changed thus making your buttons look awkward. You have no way of knowing before hand what the background color would be. If you implement a bitmap button and set its background color to the dialog box color, it might work on your system, but it might not work on other systems.
To draw a bitmap button with transparent background you need to use a mask when painting the bitmap. So you need to have two bitmaps, one that stores the normal image and the other one that has the mask. A mask is nothing but an image that corresponds to the original but the background is white and the foreground is black. You need to perform the following operations:
1. Output the normal bitmap by XOR-ing it with the target device
2. Output the mask bitmap by AND-ing it with the target device at the exact location of the original bitmap.
3. Output the normal bitmap by XOR-ing it with the target device.
At the end you will have a transparent button.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Can you give a code example?
|
|
|
|
|
I am sorry but I am away from my normal workstation, so I at this moment don't have access to my code. What I described is kind of involving, and it doesn't consists of just a few lines of code, so I cannot reproduce it right now. You need to create a CBitmapButton derived class, and then override DrawItem if I remember it correctly. Then you need to use BitBlt to perform bitwise operations. However, to avoid flicker you should not write directly to the target device. You should create a bitmap in the memory and perform the operations there. Sorry that I cannot help you with source code.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
private:
CButton Comps[5];
CRegKey reg;
.......
(reg.Open(HKEY_LOCAL_MACHINE, "Software\\ShutDown") == ERROR_SUCCESS ) {
reg.QueryDWORDValue("NumOfComputers", num);
POINT pt1, pt2;
pt1.x = 20; pt1.y = 20;
pt2.x = 120; pt2.y = 50;
ULONG Cname_sz;
char buf[20];
CString cn, Cname;
for (int i=0; i< maxComps; i++) {
CRect tmpRect(pt1, pt2);
LPCTSTR val = (LPCTSTR) itoa(i, buf, 10);
int len = Cname.GetLength();
reg.QueryStringValue(val, (Cname.GetBuffer(len)), &Cname_sz);
Comps[i].Create(_T(Cname), WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,
tmpRect, this, 1210+i);
pt1.y += 30; pt2.y += 30;
Cname.Empty();
}
.........
Best Regards,
exceter
|
|
|
|
|
Exceter wrote:
reg.QueryDWORDValue("NumOfComputers", num);
Exceter wrote:
reg.QueryStringValue(val, (Cname.GetBuffer(len)), &Cname_sz);
These functions don't exist (I am talking about VC++ 6.0, I don't know about .NET). You need to use QueryValue. I didn't check the rest of the code. You need to compile it and read the errors that the compiler will give you. I am sure that the compiler will complain very loudly by saying that QueryDWORDValue does not exist, and the same thing can be said about the rest of the code.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
reg.QueryDWORDValue("NumOfComputers", num);
reg.QueryStringValue(val, (Cname.GetBuffer(len)), &Cname_sz);
These functions exists in VC7, they do not make the error. The error is I think with the CButton array, because if I make a sinlge button (not array) the program works, that is, the dialog and the button are created.
|
|
|
|
|
reg.QueryStringValue(val,(Cname.GetBuffer(len)), &Cname_sz);
Comps[i].Create(_T(Cname),
WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,
tmpRect, this, 1210+i);
pt1.y += 30; pt2.y += 30;
Cname.Empty();
I do see something wrong with your code(but then again it is 3:43 am for me and I am very tired). Again I have never used VC7 so I could be wrong again, but a call to GetBuffer should be followed by a call to ReleaseBuffer (before you can use any other CString functions). Therefor, after QueryStringValue make a call to ReleaseBuffer.
Exceter wrote:
These functions exists in VC7, they do not make the error.
I didn't know that, that's why I refered VC6.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Yes, I gorgot to Release the buffer, thanks.
but, now I have an error in ReleaseBuffer()!!!
the error message is:
file:c:/...vc7//atlmfc/include/atlsimpstr.h
line: 718
Expression: nLength <= GetData()->nAllocLength
|
|
|
|
|
Could well be a buffer overrun then. When you do GetBuffer() instead of using the length, try specifying something like 512.
Steve S
[This signature space available for rent]
|
|
|
|
|
Greate, it works. thanx.
but, how to make it to work with Getbuffer()?
well, in this program I know the estimated sizes of the buffer, but if it exceeds the buffer size I've shoen there?
|
|
|
|
|
private:
CButton Comps[5];
CRegKey reg;
.......
(reg.Open(HKEY_LOCAL_MACHINE, "Software\\ShutDown") == ERROR_SUCCESS ) {
reg.QueryDWORDValue("NumOfComputers", num);
POINT pt1, pt2;
pt1.x = 20; pt1.y = 20;
pt2.x = 120; pt2.y = 50;
ULONG Cname_sz;
char buf[20];
CString cn, Cname;
for (int i=0; i< maxComps; i++) {
CRect tmpRect(pt1, pt2);
LPCTSTR val = (LPCTSTR) itoa(i, buf, 10);
int len = Cname.GetLength();
reg.QueryStringValue(val, (Cname.GetBuffer(len)), &Cname_sz);
Comps[i].Create(_T(Cname), WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,
tmpRect, this, 1210+i);
pt1.y += 30; pt2.y += 30;
Cname.Empty();
}
.........
|
|
|
|
|