|
2 - 5
I'm not sure what do they want me to do.
I'm sorry if this question is really stupid, I'm just really new to VS, I'm not sure where to put all of this.
|
|
|
|
|
They are VC6 instructions. Which means the code may not even compile in VC2003. I'd start by loading the project in VC2003 and see if it compiles. Adding projects to the solution is set 2.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I tried to add this to a project, but I'm not sure where am I suppose to add all this in VS2003, as I said, I've never done linking before in VS.
|
|
|
|
|
Hi,
how should I make my MFC single dialog box application so that, it could change main dialog box?
My application allows one instance (I used CSingleInstanceApp), so I want to change dialox box after user tryied to run it more time (with different parameters).
It is posible to assing CWinApp::m_pMainWnd another dialog box during aplication runs ?
rudozkv
-- modified at 5:17 Sunday 15th October, 2006
|
|
|
|
|
When you start the second instance, and you get acknowledged that another instance is running you can find that app. and send it a registered message.
Then you'll be able to handle that message in the first application.
Hope this helps.
|
|
|
|
|
Hi,
I need to sort the items in a listbox in assending/descending order. To sort in ascending order I copy the list item into a CStringList object then destroy the listbox and recreate it with style LBS_SORT . Then I add the items back again.
But how do I sort it in the descending order?
Thanks.
Fortitudine Vincimus!
|
|
|
|
|
The visual style LBS_SORT is not intended to sort anything automatically, it is only in order to allow you to click on the header of the column and receive a notification message in order to be able to handle that notification.
In other words, this is not handled automatically so you'll need to get this notification message and then sort it programatically.
Hope this helps.
|
|
|
|
|
Hi all:
Thanks for the suggestions in my original post... I think I should have worded my question differently though.
Thre original question:
"I am working on an MFC application (Visual Studio/C++) that has to grab a screen shot from a frame grabber and send it to the default printer with landscape orientation. This has to be done with no operator intervention other than clicking on a "Print" button in the main dialog - no preview or print dialog. I'm able to grab the frame, but I'm having no success with the printing."
What I really have is not a bitmap in the MFC sense, but a pointer to a big bunch of pixels. I can not seem to figure out how to get those pixels in a form that I can print - what comes out of the printer is just a black rectangle.
Again, any help would be appreciated.
Bob.
|
|
|
|
|
Did you use CreateDIBitmap[^] to get a HBITMAP? How exactly are you passing your bitmap to the printer?
|
|
|
|
|
I think you aksed this question if your problem is with bitmaps see here[^] maybe its some helpful for you
|
|
|
|
|
Hi, I've been programming for years but I learned by doing rather than by anyone teaching me, and as such I have a few gaps in my knowledge.
One is memory allocation: My question is this, if I use a locally defined buffer rather than a global buffer, does it take more overhead in terms of processor power? Also, how exactly is the memory allocated (of course the global variable is allocated when the program initiates, but what about the locally defined one? Is a new instance re-allocated each time the function is called, which would certainly cost more crunch time..?). What I'm mostly interested in is: which one is more efficient, and by how much/why?
So here's an example of what I mean.
Globally defined:
char buf[128];
void do_something()
{
buf[0] = 0;
}
As opposed to locally defined:
void do_something()
{
char buf[128];
buf[0] = 0;
}
Thanks so much!
KR
|
|
|
|
|
This is from memory so I hope I'm close...
KellyR wrote: how exactly is the memory allocated
Local one is on the stack.
KellyR wrote: Is a new instance re-allocated each time the function is called
Yes but it only takes one instruction - an adjustment to the stack pointer.
Build code with both, run it in the debugger, and check the disassembly window.
You'll see the difference in the way the array is indexed.
My guess is that in instruction cycles it's real close.
Mark
|
|
|
|
|
When the array is a local variable in the function, a new array is allocated on every call. However, all that means is the stack pointer is decremented by a different amount (an extra 128 bytes).
As for which is more efficient, the dominant effect will probably be that the local variable array will already be in the L2 cache, whereas the global array may not be on the first access.
However, unless this is in a very very tight loop, I'd be shocked if you noticed any difference in execution time. Of course, the only way to be sure it to run both versions of the code and measure.
|
|
|
|
|
Michael Dunn wrote: As for which is more efficient, the dominant effect will probably be that the local variable array will already be in the L2 cache
Cool
|
|
|
|
|
I'm trying to write a program with visual C++ 6 and I'm wanting to execute an exe file that's contained in my resources.
How do I do this?
|
|
|
|
|
|
Thanks for that. Another question: How do I write code to access the resource?
|
|
|
|
|
|
You can see an article of Mr David Crow about resource on codeproject maybe its some helpful for you
|
|
|
|
|
IDC_EDITXYZ is an edit box in dialog ABC.
IDC_LIST_Start is a list box in dialog ABC.
The first pair of lines below works. The second two pairs do not. The last line works fine.
The second pair gets compile error: 'AddString' : is not a member of 'CWnd'
The third pair gets compile error: cannot convert from 'class CWnd *' to 'class CListBox *'
OK. that's fine, but I am curious as to why the third pair doesn't work. I can understand that AddString is not a member of CWnd, but I would expect a CListBox* pointer would work since AddString is a member of CListBox. So what is the conversion from CWnd to CListBox that it can't do? What does it want?
CWnd* pEditBox = GetDlgItem(IDC_EDITXYZ);
pEditBox->SetWindowText("XYZ");
CWnd* pList = GetDlgItem(IDC_LIST_Start);
pList->AddString("XYZ");
CListBox* pList2 = GetDlgItem(IDC_LIST_Start);
pList2->AddString("XYZ");
m_List_Start.AddString("ABCDEFGHIJK");
-- modified at 18:01 Saturday 14th October, 2006
|
|
|
|
|
The compiler is unable to do a downcast like this. It has no way of knowing it's ok to
convert a CWnd pointer to a CListBox pointer (unless RTTI is used - see below).
If you use RTTI (Run-time type information) you can use:
CListBox* pList2 = dynamic_cast<CListBox*>(GetDlgItem(IDC_LIST_Start));
if (pList2)
pList2->AddString("XYZ");
or with/without RTTI use:
CListBox* pList2 = static_cast<CListBox*>(GetDlgItem(IDC_LIST_Start));
pList2->AddString("XYZ");
Either way, if you are using the control often in the dialog class it may be easier to add
a control object to the class instead
edit: ACK sorry I'm an html idiot - can't use < and > LOL
this code should look better!
Mark
-- modified at 18:18 Saturday 14th October, 2006
|
|
|
|
|
It wants this:
CListBox* pList2 =(CListBox*)GetDlgItem(IDC_LIST_Start);
pList2->AddString("XYZ");
The programmers are not humans. They are something far more superior.
Maybe some day I will too stop being a human and become one of them,
one of the X-men (or X-X-men Extraordinary-Ex-men).
|
|
|
|
|
You can declare a variable for CListBox its easy and also AddString is a function in CListBox class
|
|
|
|
|
Hello!
I’m a student and I have an assignment to research about the compatibility between Java and VC++ in socket programming, such that how a client written in Java can communicate smoothly with server written in VC++ and conversely.
I see that when a server application written in Java initialized at port 1234, why can another server written in C++ still initialize at port 1234 (on the same computer)? It need not have been able to initialize at port 1234. Why does it happen? How to avoid this? What conditions that coder has to obey when coding client and server application in the two different programming languages?
I hope someone can help me to solve this problem.
Thanks a lot.
what will be, will be ...
|
|
|
|
|
lchild385 wrote: ...why can another server written in C++ still initialize at port 1234 ...
What do you mean "initialize at port"? In C++ if you try to bind to (or listen on) the same port
you should get a WSAEADDRINUSE error.
Mark
|
|
|
|