|
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;
}
|
|
|
|
|
Thanks for the help thats exactly what I was looking for!
No my compiler didn't like the double[] void Window(double data[]) attempt, ha ha!
paddy
|
|
|
|
|
I have a quick question (okay maybe not so quick) about timing and controlling the TCP/IP stack in windows.
I developed a communications stack for an application that has to support large file tranports and smaller messages across TCP connection. The smaller (< 1K) control messages seem to work fine and the stack is able to communicate. However when I drop the big 10K message on the stack, it all seems to be writing correctly, however I am seeing a significant delay of 3 seconds between each 1k Window going out. (Note the TCP ACK comes back in around 9ms.) This 3 second delay (30 seconds total to send all 10K) seems a bit of a waste. I am going to continue to test and see if it is my machine but I believe it must be a property of the sockets. One other note is that if I send a continuous stream of the small control messages, there is no 3 second delay between packets.
I set up the socket as an overlapped socket:
m_Socket = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_IP, NULL, 0, WSA_FLAG_OVERLAPPED);
I then set the keep alive mode on, bind it to a local port, and then connect to the remote box. That all seems to work fine, except when I rely on the TCP window streaming mechanics I get that delay. The remote side even says that I have another 7K available in it's window that I could send. Is there some sort of TCP window parameter that I cannot find in the documentation??
Thanks,
Brian
If you start a fire for a man, he will be warm for a day. If you start that same man on fire, he will be warm for the rest of his life.
|
|
|
|
|
Hi!
I have a database project using MFC and ODBC. When we create a ODBC project, we obtain a CMyRecordView class derived from CRecordView. This class use a dialog template to represent data.
I want to use a CListCtrl to represent my data.
So in my class CMyRecordView.h I have declared
CListCtrl m_wndListCtrl;
In my CMyRecordView.cpp :
DDX_Control(pDX, IDC_LISTCTRL_VIEWDATA, m_wndListCtrl);
and :
void CDataBaseManagerView::OnInitialUpdate()
{
m_wndListCtrl.InsertColumn(0,_T("Item"),LVCFMT_LEFT,100);
m_wndListCtrl.InsertColumn(1, _T("Value"),LVCFMT_LEFT, 100);
m_wndListCtrl.InsertColumn(2, _T("Time"), LVCFMT_LEFT, 100);
m_pSet = &GetDocument()->m_DataBaseManagerSet;
CRecordView::OnInitialUpdate();
}
In my dialog, my control style is set to VS_REPORT
The problem is that I dont see my columns.
I see a grey bar, but I dont see any text and I dont see any line break.
thanks for helping...
|
|
|
|
|
Probably a dumb question, but . . .
Anybody can give me some tips on this? I need to create a report based on a query (which joins a couple of tables from an Access DB). The query works fine, but I can't figure out how to use it in a new report.
Any help is appreciated.
Thanks
|
|
|
|
|
Is it okay to call EndDialog in Pretranslate message?
I want the dialog to disappear when they press enter so I'm overriding the pretranslate. I just dont know if this is ok:
Pretranslate()
{
stuff...
EndDialog(IDOK);
return TRUE;
Appreciate your help,
ns
|
|
|
|
|
I'm not sure, I've never tried it. Have you experienced a problem with it?
It seems to me like your dialog box doesn't have an OK button (IDOK) but you want it to behave as if it did. If that's the case, it's a lot easier to just add a line to your dialog's message map:
BEGIN_MESSAGE_MAP(CYourDlg, CDialog)
ON_BN_CLICKED(IDOK, OnOK)
END_MESSAGE_MAP()
Regards,
Alvaro
That which does not kill me postpones the inevitable. -- despair.com
|
|
|
|
|
It seems to work okay with the "enter" exit. I do have an ok button but users are standardly used to dismissing dlgs with an enter which takes their input plus exits....
Thanks much for the response
Appreciate your help,
ns
|
|
|
|
|
As long as you have specified a Default Button, Enter acts on that, which is normally to close the dialog, so I'm confused.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|