|
Thanks for your help and suggestions.
I'm not totally sure if a better idea might be to have an array class itself and then an arrayfile class. That way i could make a generic array class that allows me to get the required functionality but in lots of arbitrary and generalised ways, and I can just have that as a data member of the arrayfile class.
|
|
|
|
|
Hehehe! It is working as intended. You are thinking in-depth about your problem domain and the design. The way you mentioned in your last post sounds good to me. Make 2 classes one for the array and another for the file reading and parsing stuff. Do a composition of both, i. e. make the array class a member of the file reading class.
Keep in mind to always start simple and extend your design as needed.
Walter
|
|
|
|
|
I written win app to launch console app write data to it and read results from it thru pipes.
My Console app on launch from command line:
type numbers:
//I'm then typing floating point numbers
1.1\n
2.2\n
3.3\n
\032\n <------ ctrl-z and new line forcing console to stop reading
//produce some output
My win app:
creates pipes;
create process; //console app
write to stdinWPipe; //console read it from its end of pipe stdinRPipe
fprintf(stdinWPipe,"%f\n",numb[i]);
frpintf(stdinWPipe,"\032\n"); //write ctrl-z symbol
closehandle(stdinWPipe); //close write end of stdin pipe
closehandle(stdoutWPipe); //close write end of stdout pipe before read
ReadFile(stdoutRPipe, ...); //read from read end of stdout pipe
This all works fine with my test console app and my win app to launch it, write data to its stdin and read data from its stdout throu pipes.
But there is just executable console which I need to lunch the same mode.
After it is ran from just command prompt it behaves exactly the same as my test console app:
type numbers: //writing prompt for typing in
1.1\n //and all the same typing numbers
2.2\n
3.3\n
\032\n //ctrl+z + \n
//and then it outputs results
But when I run this unknown console app from my win app function ReadFile(stdoutRPipe,... ) hangs itself never returning?? That is no data written to stdoutWPipe from console app. Whats the hell??
9ine
|
|
|
|
|
I did the same thing with a program I wrote in the past.. On Read I loop the read until no more data is available... Not sure how you are doing your ReadFile but this may help.
for ( ;; )
{
if(!ReadFile(hChildStdoutRdDup, chOutputBuf, sizeof(chOutputBuf), &dwRead, NULL) || dwRead == 0)
break;
chOutputBuf[dwRead] = 0;
}
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
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"
|
|
|
|
|