|
;PI have posted this question in codeguru but none reply me. My question is:
How to get a particular line height in the CRichEditCtrl. For instance, the RichEditCtrl contains total of 20 lines and each line use different character format(CHARFORMAT) to show the text, then, how can I know the height in pixels of 4th line?
Thanks in advance.
lauch2
|
|
|
|
|
All know that the vc has some Predefined Macros,such as __LINE__ ,__FILE__ etc.when the programmer write the code __FILE__ in the file myclass.cpp ,the compiler will convert it to "myclass.cpp". Now i want to create a macros __CLASS__,so when programmer write the code __CLASS__ in a class (such as CMyClass )function ,the compile will convert it to the class Name ("CMyClass"),can i realize that ?if can ,how?
CMyClass
{
void DisplayMyName();
}
void CMyClass::DisPlayMyName()
{
AfxMessageBox(__CLASS__);//When Compile it will be converted to AfxMessageBox("CMyClass")
}
thanks
|
|
|
|
|
You can't. Meditate upon the meaning of "predefined".
Even if you didn't have the "predefined" constraint, what you request can't be done without modifying the translator (compiler).
You can "work around" this by enforcing conventions, much like e.g. MFC does for its "runtime class" thingie, but there's nothing within the C++ language to help you out here.
|
|
|
|
|
You can do is something like this:
class CMyClass
{
static char const __CLASS__[];
...
void DisplayMyName();
}
...
char const CMyClass::__CLASS__[] = "CMyClass";
However in this case, __CLASS__ is not a macro and the value is not available at compile time. You can't do compile-time string concatenation.
|
|
|
|
|
Dear All
CString s("-1, 1, 10");
How can i get all of these three numbers out this string?
I used atof(s), but i can only get first number, -1.
How can i get rest of number, 1 and 10?
Thanks
|
|
|
|
|
you can define a function
CString getfirstparam(CString& strParam)
{
CString str,str1;
int i;
i = strParam.find(',');
str = strParam.left(i);
str1= strParam.right(strParam.Getlength()-i-1);
strParam =- str1;
return str;
}
|
|
|
|
|
|
I remember reading somewhere that pointer values in Windows do not use their high bit, so some applications attempt to use that bit for their own purposes. Can someone clarify this and/or point me to some more information on it? I'd also like to know if it's always safe to do this, and are their any other unused bits. Thanks.
|
|
|
|
|
In Windows, like VMS, the lower 2GB is user address space while the upper 2GB is reserved for the system. Thus, for user mode programs, the high bit is always zero. However, you can't go off and set that high bit and then expect to be able to dereference the pointer. It will still try to access the high memory and crash (I am 99.99999999% sure).
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
In Windows, like VMS, the lower 2GB is user address space while the upper 2GB is reserved for the system.
Yes. This is the case unless you have Win 2K advanced server or higher which allows the split to be 3GB user and 1GB system. For this to work you must set a switch during your link (/LARGEADDRESSWARE) and use the /3GB boot.ini switch. In any case you cannot use the high bit of a pointer for your own use and expect to dereference the pointer unless you reset the high bit before each use.
John
|
|
|
|
|
This is probably an easy one for the more experienced, so here goes:
I wish to copy the display of an off-the-shelf control, and display it on my own static control, via device contexts and bitmaps.
How would I go about this? I am guessing it'll go like:
HDC blah = somecontrol.GetDC();
CDC memDC;
memDC.CreateCompatibleDC(&blah);
myStaticControldc.BitBlt(0, 0, m_bmInfoDisplay.bmWidth, m_bmInfoDisplay.bmHeight, &memDC.dcMemory, 0, 0, SRCCOPY);
but am not having much luck so far...
Help! Please
Cheers,
Dave
|
|
|
|
|
Question is what is it suppose to do?
1) HDC blah = somecontrol.GetDC();
2) CDC memDC;
memDC.CreateCompatibleDC(&blah);
3) myStaticControldc.BitBlt(0, 0, m_bmInfoDisplay.bmWidth, m_bmInfoDisplay.bmHeight, &memDC.dcMemory, 0, 0, SRCCOPY);
1) Anything you "get" give back.. You need ReleaseDC.
2) Creates new empty CDC compatible with blah? (Why?)
3) Step 3 makes a copy of newly created empty dc into static!?
====
You need to attach control dc, and bitblt it to static.
|
|
|
|
|
I have to be able to get the bitmap from a control, so i can separately draw onto the image in my own static control. Here's revision 2:
pWnd = pDC->GetWindow(); //Get Window of PDC
pWnd->GetClientRect(&rect); //Get dimension of Window
CDC memdc;
memdc.CreateCompatibleDC(pDC); //Make Compatible DC for memdc
m_bmDisplay.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
Create Compatible DDB
pOldBmp=memdc.SelectObject(&m_bmDisplay);
memdc.BitBlt(0,0,rect.Width(),rect.Height(),pDC,0,0,SRCCOPY);
memdc.SelectObject(pOldBmp);
m_bmDisplay.GetObject(sizeof(m_bmInfoDisplay), &m_bmInfoDisplay);
Cheers,
Dave
|
|
|
|
|
Ok the entire section i have is:
BOOL CGraphStatic::SetBitmap(CDC *pDC)
{
CBitmap *pOldBmp;
CRect rect, thisRect;
CWnd *pWnd;
if(pDC==NULL)
{
AfxMessageBox("DC Not Found");
return FALSE;
}
pWnd = pDC->GetWindow(); //Get Window of PDC
pWnd->GetClientRect(&rect); //Get dimension of Window
CDC memdc;
memdc.CreateCompatibleDC(pDC); //Make Compatible DC for memdc
m_bmDisplay.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
//Create Compatible DDB
pOldBmp=memdc.SelectObject(&m_bmDisplay);
memdc.BitBlt(0,0,rect.Width(),rect.Height(),pDC,0,0,SRCCOPY);
memdc.SelectObject(pOldBmp);
m_bmDisplay.GetObject(sizeof(m_bmInfoDisplay), &m_bmInfoDisplay);
this->GetClientRect(&thisRect);
rect.right = rect.left + m_bmInfoDisplay.bmWidth + 2;
rect.bottom = rect.top + m_bmInfoDisplay.bmHeight + 2;
SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(), SWP_NOZORDER | SWP_NOMOVE);
m_bAssigned = TRUE;
return TRUE;
}
and,
in my OnPaint function for the static control (the draw struct code borrowed from somewhere, can't recall where)
if (m_bAssigned == TRUE){
if (m_cdcBufDisplay.bValid == FALSE)
{
m_cdcBufDisplay.dcMemory.CreateCompatibleDC(&dc);
m_cdcBufDisplay.pOldBmp = m_cdcBufDisplay.dcMemory.SelectObject(&m_bmDisplay);
m_cdcBufDisplay.bValid = TRUE;
}
dc.BitBlt(0, 0, m_bmInfoDisplay.bmWidth, m_bmInfoDisplay.bmHeight, &m_cdcBufDisplay.dcMemory, 0, 0, SRCCOPY);
}
If i call setbitmap on dialog initialisation, i will get at least something in the control, but anywhere else and nothing gets drawn
Cheers,
Dave
|
|
|
|
|
Your DDB SetBitmap looks fine...
Have you checked if m_bmDisplay.GetObject(sizeof(m_bmInfoDisplay), &m_bmInfoDisplay); returns correct dimentions?
Have you tried commenting // if (m_cdcBufDisplay.bValid == FALSE)
Brian
|
|
|
|
|
The correct dimensions appear to be coming from that. The first time i call the function which gets the bitmap, the bitmap copies and displays. The second time it gets called, pOldBmp=memdc.SelectObject(&m_bmDisplay); makes a debug assertion (only attach once, detach on destroy).
How can i set this up so i can continue to copy to the same bitmap?
Cheers,
Dave
|
|
|
|
|
I beleave I saw and artical on this web site on how to capture any window image to a bitmap (window, buttons, etc..). If not there is an old sample program from the Win 3.1 days that shows how to capture windows to a DIB, it should be buried in the MSDN Library some where.
Trust in the code Luke. Yea right!
|
|
|
|
|
It seems that when a client is configured to use DHCP, but there is no DHCP server present, after a 60 second timeout, an Auto IP address is assigned (using Automatic Private IP Addressing).
Does anyone know of a way to modify the duration of this timeout? Preferably to make it much shorter?
|
|
|
|
|
They just sent me W32/Lentin and I have never ever been in contact with these guys before. Do not use their services
|
|
|
|
|
CodeProject experts just need a hint about the DAta structure to use .
Say I have a grid (imagine a MSFlesgrid).
Column One has Some Names
Column two has data
OBjectName Data
MyOBject22 $1
MyObj21 $2
MyObj $3.33
Now I need to update data for each row at a fast rate . ALso Column 1 is the Key(like in databases ) .
I want something(data struct) that looks at the ObjectName (which I have as input) and retreives the Row index , so that I can I directly go to that row and update data . Like indexing . What is the exact Data structure that can help me out ?
|
|
|
|
|
hi,i'm beginner in developping program on visualc++ and i want to know how to set item for a listbox please (ex: item1,item2)?
Thanks
liuqid
|
|
|
|
|
Post an example of your code. The SetItem() function is fundamental. Let see what you have done thus far.
Kuphryn
|
|
|
|
|
m_listBox.AddString( _T("blah...") );
Dave
|
|
|
|
|
Hi, hope someone can help me out here! Is it possible to pass an array to a function? I have a double data[32768] and I want to process it in some other function but I'm not sure of the syntax used to pass the array to another function. I tried
<br />
double[] void Window(double data[])<br />
{<br />
<br />
<br />
return data[];<br />
}<br />
but obviously that didn't work!
Thanks in advance,
Paddy
|
|
|
|
|
Paddy wrote:
double[] void Window(double data[])
Did you compiler swallow this?
You should be doing something like this (if I get your point):
double *Window(double *data, size_t count)
{
return data;
}
|
|
|
|
|