|
Mukhan wrote:
char *str4 = new char[50];
Why allocate memory from the heap unnecessarily?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
a_david123 wrote:
fgets(str4,sizeof(str4),pfile);
if(str4[0]!=';')
{
fscanf(pfile,"%d",val1)
You are reading a line from the file into str4, but then you don't actually use it. Instead, you keep reading from the file using fscanf... That's why your program skips lines. Use sscanf instead of fscanf, with a format like "%d %d %d".
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
This has been shown to you many times in the past.
int row=0;
char str4[50];
pfile=fopen("filename.dat", "r");
do
{
fgets(str4, sizeof(str4), pfile);
if (str4[0] != ';')
{
sscanf(str4, "%d %d %d", arr1[row], arr2[row], arr3[row]);
row++;
}
} while(! feof(pfile));
fclose(pfile);
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
i am trying to find an instance of a small bitmap in a screen grab of a window.
so far i have managed to load both bitmaps into two BYTE arrays. I found some code which searches through the bitmaps and uses memcmp to see if the smaller one is present in the larger. the trouble is, i am having trouble with the memcmp function:
memcmp(ScreenBmp[i][tmpY],CardBmp[x], card_line_length )
What should ScreenBmp and CardBmp represent. I have the two bitmaps in BYTE buffer arrays, so how can i get them into the format above. The code i used to get them into these arrays is below:
HANDLE hBitMap = LoadImage(0, "img.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
BITMAP bitmap;
GetObject(hBitMap,sizeof(BITMAP),&bitmap);
int size = bitmap.bmHeight*bitmap.bmWidth*bitmap.bmBitsPixel/8;
/// cout << bitmap.bmHeight << endl;
BYTE *lpBits = new BYTE[ size ];
GetBitmapBits((HBITMAP)hBitMap,size,lpBits );
//delete []lpBits;
HANDLE hBitMap2 = LoadImage(0, "img2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
BITMAP bitmap2;
GetObject(hBitMap2,sizeof(BITMAP),&bitmap2);
int size2 = bitmap2.bmHeight*bitmap2.bmWidth*bitmap2.bmBitsPixel/8;
/// cout << bitmap.bmHeight << endl;
BYTE *lpBits2 = new BYTE[ size2 ];
GetBitmapBits((HBITMAP)hBitMap2,size2,lpBits2 );
cheers!
|
|
|
|
|
cmon bitches help the guy out
|
|
|
|
|
Hello All
I am using "CXListCtrl" in my application. I want to hide and show columns depending on the user selection, with some data (5 rows of data) present in the list control.
I am using "DeleteColumn" and "InsertColumn" to remove and add column
When I do "InsertColumn" a new column is added in the Header Control, in the location what i specify. When I tried to update the data for newly inserted column, progress bar is displayed and not my data.
If I try to insert 2 new columns, Columns are getting added in Header Control but in the Column values "Progress Bar" and "Check Box" are shown.
When I debugged I see the code where I update the data to corresponding new columns are getting executed correctly. After this code the following fucntion is getting called
CXListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
inside the function "(pXLCD && (pXLCD[nSubItem].bShowProgress))" is true so the following portion of the code gets executed, so Progress control is displayed!
if (pXLCD && (pXLCD[nSubItem].bShowProgress))<br />
{<br />
DrawProgress(nItem, nSubItem, pDC, crText, crBkgnd, rect, pXLCD);<br />
*pResult = CDRF_SKIPDEFAULT;
}<br />
Any Idea what is the problem?
Thanks in advance
- Ravi
|
|
|
|
|
I have an application that allows the user to bookmark different locations in a video. It saves the video images at the bookmarks. There is a listbox that shows all the bookmarks. Double-click on the listbox will bring the video to the selected bookmark position. But I'm unable to bring out the save image and display onto a picture control. I tried using CBitmap and CStatic but still unable to get the images out. I have already recode this portion dozens of times.
main problem: Getting the picture to be display. (I'm able to get the full path to the selected picture)
Can someone offer me advice on how to solve this?
Thanks
|
|
|
|
|
What format are the saved images in?
If they are BMP,JPEG,GIF you can use the OLE picture support to render them, and you could derive from CStatic to make your own picture box, or use something like the one from MSDN done by Paul DiLascia (spelling?)
Steve S
Developer for hire!
|
|
|
|
|
The images are .bmp,
I have a picture control, CStatic m_StillPic
I've tried using m_StillPic.SetBitmap() but without success.
Can you explain the parameter inside SetBitmap(),
where do I put the path to the file?
Thanks
|
|
|
|
|
Hi,
If m_stillPic is a StaticCtrl & your BMP path is "C:\\Pic.bmp" :
HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(),<br />
_T("C:\\Pic.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);<br />
<br />
if (hBitmap) m_stillPic.SetBitmap(hBitmap);<br />
m_stillPic.UpdateWindow();
|
|
|
|
|
Hi,
create a CStatic control and choose type 'rectangle'.
Use the following code to draw into that window.
void DrawBitmap(CBitmap* pBitmap, CWnd* pWindow, CPoint Offset)
{
BITMAP bmpInfo;
pBitmap->GetObject(sizeof(bmpInfo), &bmpInfo);
CSize srcSize;
srcSize.cx = bmpInfo.bmWidth;
srcSize.cy = bmpInfo.bmHeight;
CClientDC* pDC = new CClientDC(pWindow);
CDC* memDC = new CDC; memDC->CreateCompatibleDC(pDC);
CBitmap* old = memDC->SelectObject(pBitmap);
pDC->BitBlt(Offset.x, Offset.y, srcSize.cx, srcSize.cy, memDC, 0, 0, SRCCOPY);
memDC->SelectObject(old);
delete memDC; memDC = 0;
delete pDC; pDC = 0;
}
Regards
If I have seen further, it is by standing on the shoulders of giants.
Isaac Newton
|
|
|
|
|
Hi All,
I am simply adding a checkbox control in my MFC application.... after the addition of this control the application doesnt start at all... and when i remove the checkbx control, the application works perfectly.... .
Can anyone suggest the reason .... or solution to this problem ?
Thanks in advance...
mukhan
|
|
|
|
|
Mukhan wrote:
adding
Can you shortly describe how you did that ? What kind of MFC App is it ? Simply added the checkbox in the dialog editor, recompiled, and then it does not start anymore ? In Debug Mode ?
~RaGE();
|
|
|
|
|
Hi,
Its an MFC application which is getting the data from CAN bus and one thread is runnning for to get data from one PCI I/O Card.... MFC is used only for GUI. One check box is added and is been defined as CButton and BOOL in class wizard .... the same thing i did for another application which is used to get the data from xPC Target (RTOS) over TCP/IP connection... there the checkbox is working perfectly....
CButton m_check_save;
BOOL m_check_save_1;
I havent done any operation with this BOOL yet ... i just want to perform an operation if this checkbox is checked......
like
if(m_check_save_1){
// do this this .....
....
}
I am compiling it and then trying to start the application in debug mode....
Have a look now .....
|
|
|
|
|
currently, i have a large amount of data to be processed. hence, i decide to distribute the work load through several computers within LAN. i get some TCP code through code project to perform data transfer, they work well.
however, speed during the transfer is my major concern. i know TCPis slower than UDP. i plan to use UDP. i was wondering is there any code example on UDP file transfer? yup, by using winsock, not MFC. i don't want my system heavily depend on MFC.
thank you very much!
|
|
|
|
|
UDP file transfers are difficult to handle, because you have to create a re-send routine for dropped packets... you should use TCP if possible. It's much easier!
Don't try it, just do it!
|
|
|
|
|
|
I check the TrasmitFile API already. They use connection oriented instead of connectionless socket
I try my own implementation on UDP. Not so easy Most of the time, the speed of data being trasfered can be faster than the speed of data being received. Hence, if I send out 4GB, the client may only receive 1GB if the client is slow. I may implement some flow control, however, end of the day, seem like I am just re-inventing wheel
|
|
|
|
|
Hullo,
For something to quell my boredom and learn MFC, I was trying to come up with a way using MFC to enter my name and password into login boxes. What I wanted to do was have my application displaying two text boxes for my name and password with a button that when clicked would enter my name and password from the text boxes into another applications login box.
I have read about sendmessage(), but will say, Outlook allow or even be listening for this? I just need some general pointers as to which method of IPC would be best. Take it easy on me, I'm still in the early stages of MFC.
|
|
|
|
|
I am not sure if we can answer you about that, since this would be the door open to write bruteforce password breakers, if you can follow my thoughts. Sorry for that.
~RaGE();
|
|
|
|
|
Hello,
I think I understand what you want to do: you want your application that will 'remember' your password (or something like that) and when pressing the button of your application, it will fill the login and password boxes from an application.
Ok, that's nice but there are some major problems in that: first, how will your program know to which running application it must send the information ? And also, the ID's of the edit boxes (if this is always edit boxes, could be also something else) will change from applications to applications so you have no way to identify them (I may be wrong on that point as I never did that kind of things).
To respond to your question: yes, Outlook will receive the messages, it is not really 'listening' but you post messages directely in the message queue of the application so they will be processed like any other message.
|
|
|
|
|
|
Outstanding! Thanks for your help, and for being able to see through my weak explanation of where I wanted to go.
I'll post a screen shot of what i came up with later.
thanks Jose
|
|
|
|
|
I want to report something in a control similar to that in "Add or Remove Programs" of Windows control panel.
it has a list, containig all installed programs. each item of the list has some text, buttons and underlined text, multiline, and also size of each item when clicking, becomes wider.
what control is better to use?
can all of this features achieved?
|
|
|
|
|
Ali Tavakol wrote:
it has a list
Here you have it allready : I think this is a (very)derived CListView. You will have to custom draw it, and add some controls in each line (CEdit for the text, CButtons and so on).
But all this is feasible.
~RaGE();
|
|
|
|
|