|
DavidCrow wrote: What's holding w_wndOverBox and InsertString() apart?
A dot operator (sorry about the incorrect post).
DavidCrow wrote: An exception or an assertion?
An assertion:
Debug Assertion Failed...
_AFXWIN_INLINE int CCombobox::InsertString(int nIndex, LPCTSTR lpszString)<br />
{ ASSERT(::IsWindow(m_hWnd)); return (int)::Sendmessage(m_hWnd, CB_INSERTSTRING, nIndex, (LPARAM)lpszString); }
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
lctrncs wrote: An assertion:
Debug Assertion Failed...
_AFXWIN_INLINE int CCombobox::InsertString(int nIndex, LPCTSTR lpszString)
{ ASSERT(::IsWindow(m_hWnd)); return (int)::Sendmessage(m_hWnd, CB_INSERTSTRING, nIndex, (LPARAM)lpszString); }
Which indicates you have a non-existent window. At what point are you trying to populate the combobox?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I populate the combobox in OnInitDialog - which is only called upon dialog start and after a change to the database such as adding or deleting a record.
I am trying to clear the dropdown style edit box (drop list style would be preferred due to the static edit box) from my DisplayRecord function (called at the end of OnInitDialog), and this is where I have instantiated m_wndComboBox, and from where I call m_wndComboBox.InsertString(0,"",0).
The control exists on a modeless dialog, which is trying to open at the time of the assert.
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
lctrncs wrote: ...this is where I have instantiated m_wndComboBox...
m_wndComboBox should be a member variable, not local to some function.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
As I said, I have never tried to instantiate a class instance so that I can use the dot operator.
I tried to instantiate it in a number of locations (mainframe.cpp main.c etc.) without success.
So where should I instantiate my m_wndCombobox so that I can use the dot operator as you suggest
m_combo.InsertStinrg(0,"")
?
Why should the dot operator work when a pointer does not?
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
lctrncs wrote: So where should I instantiate my m_wndCombobox so that I can use the dot operator as you suggest
It should belong to the class that owns it (hence the m_ prefix). In my example, m_combo and m_list are both members of CMyDialog .
lctrncs wrote:
Why should the dot operator work when a pointer does not?
Pointer variables use ->, while non-pointer variables use a dot. In reality,
pointer->member is equivalent to:
(*pointer).member See here for more on the member-selection operator.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
So I should right click on CDialog, choose Add Member Function and enter Ccombobox and m_combo to instantiate m_combo as a member CDialog?
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
lctrncs wrote: So I should right click on CDialog, choose Add Member Function and enter Ccombobox and m_combo to instantiate m_combo as a member CDialog?
No. Use ClassWizard (Ctrl+W) to associate a member variable with a control.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hi there!
im trying to write a graphing app using the win32 api with MFC...
im trying to figure out how i can represent a decimal number position in a grid of pixels:
i.e.
given y = sqrt(x)
if i calculate with x = 5.7 then y becomes 32.49 which is a bit of a problem because no pixel exists at 32.49, so the line gets drawn at y = 32, so the graph curve is messed up because the curves arent matching up because of the round-off error...
im trying to draw the line using the MoveTo and LineTo functions, and if i can figure out a way to draw the correct pixel corresponding to the equation then i can use a very low incremental value such as 0.1 to make the curve look smooth, though its not really smooth...
but if theres a better way of drawing a graph app (without using bezier curves or whatever) please could u let me know!
hope u can help me out! thx!
|
|
|
|
|
If yu are going to use LineTo to draw your lines, then you are going to have to draw them using very small increments, and the round-ff errors are not going to be that noticeable. If you are trying to draw the curve for squares or square-root values, for example, you need to keep your increments as small as possible to produce a "smooth" effect. Otherwise you are going to have to use some othe mathematical functions expressly written to display curves in a very smooth format. You can get more help on the internet about those than I can explain here. Good luck
John P.
|
|
|
|
|
Hey all,
I've run into a small problem. When Windows generates an HDC on its own (for a paint message) it uses the clip region to determine the update area. If you call GetClipBox() the coordinates start at 0,0. If that region is a portion of a larger window I would need to know where that area is in relation to the entire window.
Is there a function that can translate the HDC coordinate space into one that maps onto the window rect (or some other global space?)
Thanks!
ant
|
|
|
|
|
ClientToWindow or ClientToScreen might help
|
|
|
|
|
Thanks, but it is ambiguous. The window client region will have a 0,0 defined as the upper left corner of the window. The HDC (which is in the same client area) will also have a 0,0 defined which is not necessarily the same location. While ClientToScreen() will convert the point, it will convert it assuming the window coordinate space and not the HDC coordinate space. In order for ClientToScreen to work it would have to take the HDC as an argument.
Thanks for the suggestion, but it didn't work.
|
|
|
|
|
Screen coordinate space: relative to the screen.
Window coordinate space: relative to the window.
Client coordinate space: relative to the client area of a window (excluding title bar, border, menu, etc.)
For a given HDC, there will be two (potentially different) coordinate systems: device coordinates and logical coordinates.
For device coordinates, the origin, orientation, precision, etc. are determined by the device on which output is to be displayed: for the screen, these are usually relative to the window for which the device context was requested, with (0,0) at the top left, y increasing downwards, with pixel units (contrast with printers, which might have (0,0) at the bottom left, y increasing upwards, units being in something that makes sense for the type of printer). BeginPaint() , for instance, returns a device context for the client area of the window being painted.
Logical coordinates, controlled via SetMapMode() , can have a different origin, orientation, and unit size than those of the device that they eventually map to (MM_TEXT == 1-1 mapping to device units, MM_INCHES == 1" units, bottom left origin, y increases upwards, etc.)
The update region is merely an area within a given window marked as needing to be redrawn. BeginPaint() will set the clipping region to this area and erase it, but it does not determine how coordinates are mapped to the output device - it is useful only as an aid in determining what portion of the window needs to be redrawn (similarly, the clipping region is used to avoid redrawing portions of the screen - initially, it is set to the client area of the window (for client HDCs)).
See also:
Guide to Win32 Paint[^]
|
|
|
|
|
Thanks to everyone who provided insight. In the end I guess my description wasn't clear enough to explain the problem since it is a rather bizarre situation. Mixing MFC/Win32 can give odd results at times and this is one of those times! I'm looking into a workaround right now which is starting to look promising. If however anyone else has suggestions please make them!
Thanks!
ant
|
|
|
|
|
Can someone please explain to me the difference between a Linked list and an array... I'm a starter to programming and wish to know how linked lists work and where they are applied. Cheers
|
|
|
|
|
An array is a set of contiguous memory allocated for a set of objects. For example, if you have an array of 10 integers, you will have a memory section the size of 10 integers (with 4-byte integers, that is 40 bytes) allocated to hold them.
Linked lists hold extra pointers to previous and next elements in the list in addition to the object you want. The memory is not contiguous, so when you add a new element to the list, memory is allocated for that element (and the pointers to its next and previous elements in the list).
Arrays (or vectors) are used when you need fast random access to elements. Linked lists are used when you need quick insertion/removal of elements.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: Linked lists are used when you need quick insertion/removal of elements.
Unless you have an ordering requirement...
--
The Show That Watches Back
|
|
|
|
|
The explanation you've been given is most excellent. I'll just add that the book to buy on this stuff is called Mastering Algorithms in C. The code is in C, but the point is that the book explains all of these containers and also some algorithms ( sorting, etc ) in a way that leaves you fully understanding how they work, and the trade offs in choosing a particular container for a task.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I used the CHtmlView to display a web page ,and I want to paint some rectangle to divide the page into some blocks. How to implement it? I am looking forward to your replay. Thank you in advance
|
|
|
|
|
I don't think you want to "paint" ( in the WM_PAINT way ) a rectangle in an HTML view.
You better try to modify the HTML source itself.
|
|
|
|
|
I call the ReadDirectoryChangesW() function in my project.
the compiler show error message about
error C2065: 'ReadDirectoryChangesW' : undeclared identifier
Please give me some recommend for solve this problem
|
|
|
|
|
|
why don't you just use ReadDirectoryChanges() (without W) ?
|
|
|
|
|
See here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|