|
Good C tutorial needed.
Hint: string literals must be enclosed by double quotes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
CPallini wrote: Good C tutorial needed.
Hint: string literals must be enclosed by double quotes.
would refer him/her for good C book
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
gentleguy wrote: MessageBox(buff,'number%d');
What in the world is this? The documentation plainly shows that MessageBox() expects four arguments.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I have been created a tab control in dialog box (we called as Dialog Main). I add 3 frameless dialog box (we called as dialog A, Dialog B, Dialog C) in the tab control. The tab control working fine. I add three button (OK button, Cancel button ,Apply Button) in each frameless dialog box. However, when I clicked Cancel button in dialog A only dialog was closed. I want all dialogs(Dialog Main, dialog A, Dialog B, Dialog C) to be closed when I clicked OK of Cancel button inside each frameless dialog box(dialog A, Dialog B, Dialog C). Please anybody help me???
|
|
|
|
|
cb02061 wrote: hen I clicked Cancel button in dialog A only dialog was closed. I want all dialogs(Dialog Main, dialog A, Dialog B, Dialog C) to be closed when I clicked OK of Cancel button inside each frameless dialog box(dialog A, Dialog B, Dialog C). Please anybody help me???
Use AfxGetMainWnd()->PostMessage( WM_CLOSE ).
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Hi,
Actually i'm calling dialog box from SDI application.
When i use Use AfxGetMainWnd()->PostMessage( WM_CLOSE ) the whole application was closed.
I just want just dialogs(Dialog Main, dialog A, Dialog B, Dialog C) to be close.
|
|
|
|
|
cb02061 wrote: Actually i'm calling dialog box from SDI application.
cb02061 wrote: AfxGetMainWnd()->PostMessage( WM_CLOSE ) the whole application was closed.
I just want just dialogs(Dialog Main, dialog A, Dialog B, Dialog C) to be close.
You can then post this message(WM_CLOSE) to your dialog, or call EndDialog on this main dialog of yours.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Can u please explain me by sample codes?? Thanks a lot for ur reply
|
|
|
|
|
cb02061 wrote: Can u please explain me by sample codes??
GetParentOwner()->PostMessage( WM_CLOSE );
or
::EndDialog( GetParentOwner()->GetSafeHwnd(), IDCANCEL );
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Thanks a lot...It's working fine...
|
|
|
|
|
cb02061 wrote: I have been created a tab control in dialog box (we called as Dialog Main). I add 3 frameless dialog box (we called as dialog A, Dialog B, Dialog C) in the tab control.
It sounds like you'd be better served by a property sheet (with three property pages). In this context, the buttons would belong to the whole sheet rather than a particular page. Way cleaner than your current design.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I use CWebBrowser2 to open web page:
CWebBrowser2 m_webBrow2;
m_webBrow2.Navigate("http://www.google.com",NULL,NULL,NULL,NULL);
When web page has been opend, I can put "my search" into google's search edit control by keyboard and press search button by mouse.
But, how to do these by C++ code?
Is CWebBrowser2 have member can do this?
|
|
|
|
|
hanlei0000000009 wrote: m_webBrow2.Navigate("http://www.google.com",NULL,NULL,NULL,NULL);
Directly use a search query string. Modify navigation string to include the search term too! Click on this link and see what happens, and the same you can do with the navigate function!
http://www.google.co.in/search?q=CodeProject+Nibu+Babu+Thomas[^]
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
modified on Tuesday, June 17, 2008 11:24 PM
|
|
|
|
|
thanks.
But, google.com only a sample. If web page is an other and if after press a button web page not change to another page?
So, I cannot work on all web page by this way.
|
|
|
|
|
good question, i'm trying this to for a while but I haven't found anything, do you?
|
|
|
|
|
I have DIB information - header and color array retrieved from video frame.
I like to get very basic histogram of RGB colors. I am having difficulty understanding the difference between bitmap dimesions biWidth, biHeight and biSizeImage. All in bytes.
I understand that the biSizeImage is much larger than simple width*height because it does scan lines adjustment and other stuff.
If I run do ( ….) while (count != width*height) I must be “counting” some of these adjustments, right?
But if I run do(…) while (count != biSizeImage) it asserts probably because it runs out of real bitmap data.
(I have not traced it all the way to the point of assertion.)
So – how do I skip over the “fillers” or do I have to run GetDIBits and build another data buffer?
Thanks for reading
Vaclav
I think I found the solution - two nested for loops from 0 to width/ height. Testing.
modified on Tuesday, June 17, 2008 9:05 PM
|
|
|
|
|
Vaclav_Sal wrote: I think I found the solution - two nested for loops from 0 to width/ height.
Yes
Example:
LONG stride = (((bmiHeader.biWidth * (long)bmiHeader.biBitCount + 31L) & (~31L)) / 8L);
RGBTRIPLE *CurrentRow = ...address of beginning of pixel data...;
for (int y = 0; y < bmiHeader.biHeight; ++y)
{
for (int x = 0; x < bmiHeader.biWidth; ++x)
{
... do something with CurrentRow[x].rgbtRed ...
... do something with CurrentRow[x].rgbtGreen ...
... do something with CurrentRow[x].rgbtBlue ...
}
CurrentRow = (RGBTRIPLE *)((BYTE *)CurrentRow + stride);
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark,
somehow I knew that simple loops won't work.
Vaclav
|
|
|
|
|
You can use a single loop as long as the values of any possible row
padding bytes doesn't affect your math, but you still have to know
the extra bytes may be there.
Also, biSizeImage is allowed to be 0 - you need to check for that and calculate
the value if it is:
if (0 == biSizeImage)
biSizeImage = stride * abs(biHeight);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark , thanks for the addendum.
But I spoke too soon. My code still asserts. My bitmaps size is 320 wide and 240 high and it asserts in about half height. I must have screwed up something. It looks like I do not have 24 bit biBitCount.
But right now I have another pressing issue ( babysitting my new grandson!)so this one is temporary on hold. Here is my code in case you want a good laugh.
As always "->" are = -> !
I do not understand why this editor does that to my code! Tired of "fixing it"!
PS. It seems to make no difference if I use casts as you suggested.
RGBQUAD *CurrentRow;
//lpBi->bmiHeader.biBitCount = 32;
LONG stride = (((lpBi->bmiHeader.biWidth * (long)lpBi->bmiHeader.biBitCount + 31L) & (~31L)) / 8L);
if(lpBi->bmiHeader.biBitCount == 24)
CurrentRow = lpBi->bmiColors; // 24bpp pixel data - use RGBQUAD
else
{
//AfxMessageBox("Unsuported bitmap format");
}
CurrentRow = lpBi->bmiColors;
for (int y = 0; y < lpBi->bmiHeader.biHeight; ++y)
{
for (int x = 0; x < lpBi->bmiHeader.biWidth; ++x)
{
iRed = CurrentRow[x].rgbRed;
iGreen = CurrentRow[x].rgbGreen;
iBlue = CurrentRow[x].rgbBlue;
/*
histogram[RED][iRed] += 1;
histogram[GREEN][iGreen] += 1;
histogram[BLUE][iBlue] += 1;
*/
icount++;
}
CurrentRow += stride;
}
|
|
|
|
|
Change
CurrentRow += stride; to
CurrentRow = (RGBQUAD *)((BYTE *)CurrentRow + stride); I changed that in my original reply code
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi there,
I'm really stumped with the memory re-allocation with a CListCtrl in MFC after using the SetItemData function
and was wondering if any of you could help me out.
Here goes:
I have a class MyClassX which I instantiate using MyClassX * myClassInst = new MyClassX();
I add this instance to a CListCtrl myListCtrl using the following: myListCtrl.SetItemData( lineX, (DWORD)myClassInst );
This is all well and fine and I am able to retrieve the data and work with it, all happiness, however here is my problem.
When the time comes to delete this class, I step through each entry in the list pulling out its data item with
MyClassX * tmpClassX = (MyClassX*)myListCtrl.GetItemData(index);) and subsequently call delete tmpClassX; which deletes the instance no problem.... however, closer examination on the memory tells me otherwise. Even though the destructor of the MyClassX was called, and the instance no longer exists, the memory allocated for the class does not free.
I've tested the deletion process without adding the class to the CListCtrl and my memory is always reclaimed, however once adding the data to the list, the memory is never freed. (After first physically deleting the created classes, then calling DeleteAllItems on the list).
This is very puzzling to me and I'm beginning to wonder if some malloc operation goes on inside the CListCtrl once the SetItemData is called, but the memory is never de-allocated once cleared.
Should I create a "light weight" struct with a (void *) pointer and an index and just add this struct to the list rather?
Should I override the DeleteAllItems call in a custom list?
I’m absolutely puzzled!!
Thanks in advance...
|
|
|
|
|
Psyinx wrote: ...the memory allocated for the class does not free.
How are you verifying this?
Psyinx wrote: ...I'm beginning to wonder if some malloc operation goes on inside the CListCtrl once the SetItemData is called, but the memory is never de-allocated once cleared.
How would the list control know that you've deleted the memory pointed to by the call to GetItemData() ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: How are you verifying this?
Simple: The application that is using the list revolves around an extreme amount of incoming data. After the usual steps of creating the structure that will be used inside the list, instead of adding it to the list, i delete it, using the same deletion code i use upon clearing the list.
Watching the applications memory usage with the list added data, the memory can grow from 30mb to 150 within a matter of 5 minutes.
Without adding the data to the list, the application remains constant at 30mb.
I've made 100% sure that after adding the classes to the list that my garbage collection is done once the list is cleared
(for every constructor called i increment a counter, for every destructor called i decrement the counter, and lo and behold, it
shoots to 2000 at max (my ceiling for the list), then back down to 0 once their destructors are called.)
I know for a fact that the destructor code is cleaning up the object as without the list, the memory is constant.
DavidCrow wrote: How would the list control know that you've deleted the memory pointed to by the call to GetItemData()?
This is a good question.. However once the object has been deleted, it should automatically reclaim the memory from that object that has been deleted.. or at least this is what should happen in theory (and does happen without the call to SetItemData), also what confuses me is that i'm handing the SetItemData a pointer, and not the actual "data", and the last time i checked, 2000 pointers do not add up to 120mb..
I'm definitely missing something here! Am i assigning the data incorrectly? Deleting the data incorrectly? Clearing the list incorrectly? I'm really stumped!
Is there a message that i can send the list to inform the list that the data has been deleted?
Thanks.
|
|
|
|
|
Psyinx wrote: Watching the applications memory usage...
Using?
Psyinx wrote: However once the object has been deleted, it should automatically reclaim the memory from that object that has been deleted...
That is not the way Windows' memory manager works.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|