|
I've figured out the reason.
This executable first writes to stderr so it was useless to read from stdout untill this program accepted data in stdin. So this is why readfile suspends itself if trying to read from stdin.
9ine
|
|
|
|
|
Hi,
how can i get a handle to my current window class?, i mean from within the class, if its possible at all.
and is there any way to convert between both HWnd and CWnd , f.e a function that takes a handle and returns a pointer ?
thanks
|
|
|
|
|
CWnd::FromHandle() [^]
Vini
|
|
|
|
|
saadani wrote: is there any way to convert between both HWnd and CWnd , f.e a function that takes a handle and returns a pointer ?
HWND to CWnd *
CWnd *pWnd = CWnd::FromHandle(aHwnd);
CWnd to HWND
HWND aHwnd = pWnd->GetSafeHwnd();
saadani wrote: how can i get a handle to my current window class?, i mean from within the class
HWND hWnd = this->GetSafeHwnd();
Nibu thomas
Software Developer
|
|
|
|
|
From the Documentation of the CWnd-Class:
CWnd::m_hWnd
Remarks
The handle of the Windows window attached to this CWnd. The m_hWnd data member is a public variable of type HWND.
CWnd::GetSafeHwnd
HWND GetSafeHwnd( ) const;
Return Value
Returns the window handle for a window. Returns NULL if the CWnd is not attached to a window or if it is used with a NULL CWnd pointer.
Hope this helps you out.
Walter
|
|
|
|
|
|
Hi Guys,
I have a list control containing 3 columns, When i click on any item in the list box it again pops up a combo box. But problem is that when i am tring to increase the height of the combo box it's not increasing and reamain same always. I am giving you the whole code. please tell me how to fix this problem. I am trying to increase the rect.bottom but its not increasing.
void CListAgr::OnListLButton(WPARAM wParam, LPARAM lParam)
{
UINT nFlags = lParam;
int iItem = wParam;
int iItem = m_list_Agr.GetNextItem(-1, LVNI_SELECTED);
if (iItem >= 0)
{
CRect rect;
int offset = 0;
// Make sure that the item is visible
m_list_Agr.GetSubItemRect(iItem, 1, LVIR_BOUNDS, rect);
// Now scroll if we need to expose the column
CRect rcClient;
m_list_leaseabs.GetClientRect(rcClient);
if( offset + rect.left < 0 || offset + rect.left > rcClient.right )
{
CSize size;
size.cx = rect.left;
size.cy = 0;
m_list_leaseabs.Scroll(size);
rect.left -= size.cx;
}
rect.left += offset;
rect.right = rect.left + m_list_Agr.GetColumnWidth(1);
if(rect.right > rcClient.right)
rect.right = rcClient.right;
//basic code end
rect.NormalizeRect();
rect.bottom += 10 * rect.Height();//dropdown area "PLEASE SEE THIS"
rect.left += 10;
rect.right += 10;
rect.top += 30;
CStringList lstItems;
lstItems.AddTail("X");
lstItems.AddTail("Y");
lstItems.AddTail("Z");
CComboBox *pADFList = new CComboInListView(iItem, 1, &lstItems);
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_VSCROLL |
WS_HSCROLL|CBS_DROPDOWNLIST | CBS_DISABLENOSCROLL;
pADFList->Create(dwStyle, rect, this, IDC_COMBOBOXINLISTVIEW);
pADFList->ModifyStyleEx(0,WS_EX_CLIENTEDGE);//can we tell at all
pADFList->SetHorizontalExtent(m_list_Agr.GetColumnWidth(1));
pADFList->ShowDropDown();
pADFList->SelectString(-1, m_list_Agr.GetItemText(iItem, 1));
}
}
|
|
|
|
|
I could not check all of your code, but you can try this:
Remove the CBS_DISABLENOSCROLL style from the Combobox.
See if that helps.
this is this.
|
|
|
|
|
No it's not working. As per MSDN
CBS_DISABLENOSCROLL: The list box shows a disabled vertical scroll bar when the list box does not contain enough items to scroll. Without this style, the scroll bar is hidden when the list box does not contain enough items.
If possible then check the code we are missing fundamental concept like it's mapping mode or something.
|
|
|
|
|
|
Hi,
I'm running into some issues with my custom created class..
A simplified version:
ref class cCollection<br />
{<br />
public:<br />
int id;<br />
array< Point >^ points;<br />
char* name;<br />
};
Declared an array for it with:
<br />
array< cCollection^ >^ aCollection;<br />
<br />
array< cCollection^ >^ aCollection = gcnew array< cCollection^ >(99);
The application compiles, builds, and runs, but when i try to add an element in my btnAdd_Click event with:
<br />
iCount++;<br />
<br />
cCollection^ tempCollection = gcnew cCollection;<br />
<br />
aCollection[iCount] = tempCollection;
...the application crashes with "aCollection contains < undefined value > "
I hope you see my target; I have a class cCollection and i'd like to put them in an array.. I lost track with the fact that my array contains managed elements (points).
Could someone please help me out? thanks in advance,
joost
-- modified at 7:51 Wednesday 1st March, 2006
|
|
|
|
|
This looks like managed C++. Yes?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Indeed.. The use of Points requires the use of it. At least, that's what i can make up out of the errors i receive during the development of this small application.
Thanks for your reply,
joost
-- modified at 9:38 Wednesday 1st March, 2006
|
|
|
|
|
The problem is solved with:
array< cCollection^ >^ aCollection; <br />
<br />
aCollection = gcnew array< cCollection^ >(99);
|
|
|
|
|
Hi ,
As i know the data read and write from a hard disk in a file is bit a slow process,
So i want read a data from file and load it into a memory to do some operations on data and then i want to write that all data inot a file , so read and write will b only for once.
actualy i dont want the continoius read and write to a hard disk,
so how can i load the all file contents in a memry and read them from memoery , and how can i write a that memory data into a file
Thanks
Regards.
|
|
|
|
|
Create a file.
pass that handle as first parameter in the function CreateFileMapping()
now pass the hanle return from the function CreateFileMapping to the function
MapViewOfFile().
The function MapViewOfFile() returns a pointer to the buffer. u can do read and write to thst buffer. Finally u have to call UnMappviewoffile() when u exit.
nave
|
|
|
|
|
zahid_ash wrote: so how can i load the all file contents in a memry...
char buffer[2048];
DWORD dwBytesToRead = sizeof(buffer),
dwBytesRead;
ReadFile(hFile, &buffer, dwBytesToRead, &dwBytesRead, NULL);
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hi there,
i have written this function to draw a image held in raw pixel data in my own class to a window. It is not working as expected, say it doesn't draw a single pixel. Where is the fault? I am trying to solve this for days now and can't see where i made the mistake. Here comes the code.
void CImageViewerView::drawImage(CDC* pDC, CpilImage* pImage) {
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CBitmap imageBitmap;
BITMAP bmp;
BYTE* imageBits;
BYTE* pImageBits;
imageBitmap.CreateBitmap(pImage->getWidth(), pImage->getHeight(), 1, 24, NULL);
imageBitmap.GetBitmap(&bmp);
imageBits = (BYTE*) GlobalAlloc(GPTR, bmp.bmHeight * bmp.bmWidthBytes);
for (unsigned int y = 0; y < pImage->getHeight(); y++) {
unsigned int* line = pImage->getPixelRegion(0, y, pImage->getWidth(), 1);
unsigned int* pLine = line;
pImageBits = imageBits + (bmp.bmWidthBytes * y);
for (unsigned int x = 0; x < pImage->getWidth(); x++) {
pImageBits[0] = getRedValue(pLine);
pImageBits[1] = getGreenValue(pLine);
pImageBits[2] = getBlueValue(pLine);
pImageBits += 3;
pLine++;
}
}
if (imageBitmap.SetBitmapBits(bmp.bmHeight * bmp.bmWidthBytes, imageBits) == 0) {
AfxMessageBox("Could not set bitmap bits.");
}
GlobalFree((HGLOBAL) imageBits);
CBitmap* pOldBitmap = memDC.SelectObject(&imageBitmap);
if (pDC->BitBlt(0, 0, pImage->getWidth(), pImage->getHeight(), &memDC, 0, 0, SRCCOPY) ==0) {
AfxMessageBox("BitBlt failed.");
}
memDC.SelectObject(pOldBitmap);
}
CpilImage is a class which stores a image plus the pixel data in rgb-quads. The getXXXValue() -functions are utility functions which extract the red, green and blue values from the quads. The class and functions are working, cause if i alter the function to work with CDC::SetPixelV() the image is drawn. But as this is very slow i tryed to speed it up with SetBitmapBits() and BitBlt() which seems to not work.
Walter
|
|
|
|
|
i am prety sure no one wants to read long code as in ur post.
1. bitmap width must be aligned with 2 or 4 bytes.
2. bottom-up or top-down bitmap is determined by BITMAPINFIHEADER.dbHeight.
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
-- modified at 8:12 Wednesday 1st March, 2006
|
|
|
|
|
I tryed to cut it down, but i thought everything could be important. But your post shows that you haven't read the code, either. I use the calculated width from the bitmap info header bmWidthBytes. This is calculated by windows and 4 bytes aligned. I put traces in there and the height is calculated correct. If any of this values would be false there should be something on the screen at last and if it is only crap. But there is nothing, not a single pixel.
I try to break the code down a bit:
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CBitmap imageBitmap;
BITMAP bmp;
BYTE* imageBits;
BYTE* pImageBits;
imageBitmap.CreateBitmap(pImage->getWidth(), pImage->getHeight(), 1, 24, NULL);
imageBitmap.GetBitmap(&bmp);
imageBits = (BYTE*) GlobalAlloc(GPTR, bmp.bmHeight * bmp.bmWidthBytes);
if (imageBitmap.SetBitmapBits(bmp.bmHeight * bmp.bmWidthBytes, imageBits) == 0) {
AfxMessageBox("Could not set bitmap bits.");
}
GlobalFree((HGLOBAL) imageBits);
CBitmap* pOldBitmap = memDC.SelectObject(&imageBitmap);
if (pDC->BitBlt(0, 0, pImage->getWidth(), pImage->getHeight(), &memDC, 0, 0, SRCCOPY) ==0) {
AfxMessageBox("BitBlt failed.");
}
memDC.SelectObject(pOldBitmap);
|
|
|
|
|
Instead of using CreateBitmap() , use CreateCompatibleBitmap() passing pDC as the DC parameter, and then use the contents of the BITMAP structure to determine what format the bitmap is in. You may very well find that it's a 32-bpp bitmap, not a 24-bpp bitmap. Remember BitBlt() only works if the source bitmap is monochrome or in the same format as the device context - hence the CreateCompatibleBitmap() function.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Yeah! Just found out that this is the problem. It seems SelectObject() for the bitmap is returning an error, because of the bitmap is not compatible with the device context. I think i change my strategy and have a look into device independent bitmaps (DIB). Maybe this solves my problem.
Programming Windows API can be frustrating sometimes. The only thing i want to do is to put some raw 24bit RGB pixel data fast on to the screen. This can't be that difficult.
Thanks for your help!
|
|
|
|
|
I just noticed what you're trying to do
Have a look at CreateDIBitmap() and SetDIBitsToDevice() . They will work with any bitmap format and will convert between them when displaying the bitmap. Slower than BitBlt() , but the performance will be substantially quicker than what you are doing here.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Looks like i am on the right way now. Thanks again.
|
|
|
|
|
How is it possible to correctly allign the seperate parts of a status bar under Win32? I know we have to create an array of ints each defining the right side of the part and send the SB_SETPARTS message. But what about alligning the parts on the right hand side?
I want my bar to look similar to this one http://www.codeproject.com/miscctrl/ProgressBar.asp[^]
The only method I can think of is by getting the status bar rect and setting the parts according to the width, but this kinda gets screwed up when it comes to resizing. Even so, in the picture there is a large space blank space before the parts which I am so far unable to reproduce.
|
|
|
|