|
The messages are sent to the trackbar control's parent by default.
You could right click the parent window class in the class view window,
choose properties, select the messages tab in the properties window,
and add the WM_VSCROLL handler there.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
In the MSDN source code for some GDI+ methods, the authors use malloc and free. Why would they do this if RectF is a class? Is this a hint that it is merely the equivalent to a struct with the ctor and dtor doing nada? Should we follow this convention or use new/delete instead?
Here's an example for GetRegionScans()...
VOID Example_GetRegionScansRect(HDC hdc)
{
Graphics graphics(hdc);
SolidBrush solidBrush(Color(255, 255, 0, 0));
Pen pen(Color(255, 0, 0, 0));
GraphicsPath path;
Matrix matrix;
Rect* rects = NULL;
INT count = 0;
path.AddEllipse(10, 10, 50, 300);
Region pathRegion(&path);
graphics.FillRegion(&solidBrush, &pathRegion);
graphics.GetTransform(&matrix);
count = pathRegion.GetRegionScansCount(&matrix);
rects = (Rect*)malloc(count*sizeof(Rect));
pathRegion.GetRegionScans(&matrix, rects, &count);
for(INT j = 0; j < count; ++j)
graphics.DrawRectangle(&pen, rects[j]);
free(rects);
}
modified on Tuesday, December 04, 2007 1:45:44 PM
|
|
|
|
|
bob16972 wrote: Why would they do this if RectF is a class?
Does its constructor/destructor do anything?
Keep in mind that just because it's an MSDN sample, that does not imply it's also perfect code. Folks that supply samples to MSDN are not infallible. MSDN does provide lots of great code, some of which can be used unaltered, but it should still be scrutinized regardless.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: Does its constructor/destructor do anything?
I'm not sure the GDI+ source code is available for inspection (except the declaration files of course)
DavidCrow wrote: Keep in mind that just because it's an MSDN sample, that does not imply it's also perfect code. Folks that supply samples to MSDN are not infallible. MSDN does provide lots of great code, some of which can be used unaltered, but it should still be scrutinized regardless.
I understand what your saying. I was scrutinizing it and I couldn't determine why they were doing it. I thought I'd post the question to see if it made sense to anybody and if they could explain what benefits the author is realizing here or if the code is flawed.
Thanks for the input.
|
|
|
|
|
Hi, I gess is using malloc and free to avoid a loop for alocation a "count" number of Rect objects, alocation all of them in one malloc
look at
malloc(count*sizeof(Rect)<code> parameter of malloc.<br />
<br />
<br />
<br />
|
|
|
|
|
Hi
there is a dll with cpp and h and lib file that is usable in VC++ we need to define it and use it in VB or VC# please help me.
Best regards
|
|
|
|
|
|
Does anyone know of any free alternatives to using iexpress.exe to package an installer/msi into a self-extracting/self-installing executable? I've been using iexpress until I upgraded to Vista/VS2008 and now whenever I run a package I get the error "This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package."
{o,o}.oO( Did somebody say MouseDown? )
|)””’)
-”-”-
|
|
|
|
|
Hi,
I am working on an application which generates a tree data structure. Whilst this can be presented to the user using the standard windows tree control; I feel that the data would be best represented as a heirarchy:
(please ignore initial dots)
.....[ ]<br />
..../ | \<br />
..[ ][ ][ ]
I have been searching the net extensively for an algorithm which computes the output rectangle for each node. I have not been able to find anything of use; however on one website somebody mentioned Walker's algorithm.
It would be great if somebody could either explain or refer me to a useful resource which details how this could be achieved.
I intend to use the MFC framework when drawing the tree.
Any advice would be greatly appreciated!
Lea Hayes
|
|
|
|
|
I spent 18 months on and off on exactly this problme when I was 12-13 and writing a family history app. I was laying out descendant trees and struggled with getting them correctly organised for a long time. In the end I found a 3 pass algorithm worked best. Top down to get the structure and child groupings. Bottom up to establish the required width for the descendants of each node and then top down again to centre each set of child nodes under the parent/parents. I was very proud of my tree layout algorithm although I'm sure it's pretty standard stuff and in lots of books. My mother's second cousin tried to commercialize the app wihtout crediting me but as far as I know it didn't work out.
I was highly ammused when I got my first copy of MS Windows and found MS had outsourced development of the organisation chart application. Perhaps I could have made some money out of my trees after all
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Matthew Faithfull wrote: My mother's second cousin tried to commercialize the app wihtout crediting me
Nice guy.
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.
|
|
|
|
|
To draw the 2D Tree, first you need to find out the maximum width of the tree, which means you need to use BFS solution to iterate the tree.Once you have done that, you can draw whatever you want.
|
|
|
|
|
Hello everyone,
Why the below code segment will result in compile error? When I change code to the comment one (constructor), it can compile. The compiler is too stupid?
I am using Visual Studio 2005.
--------------------
main.cpp(13) : error C2758: 'Foo::vi' : must be initialized in constructor base/member initializer list
see declaration of 'Foo::vi'
--------------------
#include <vector>
using namespace std;
class Foo {
private:
vector<int>& vi;
public:
Foo (vector<int>& vi_in)
{
vi = vi_in;
}
};
int main()
{
vector<int> vi;
Foo foo = Foo (vi);
return 0;
}
thanks in advance,
George
|
|
|
|
|
George_George wrote: The compiler is too stupid?
Nope.
Reference types need initialization. See there http://www.devx.com/getHelpOn/10MinuteSolution/17298/1954?pf=true[^]
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.
|
|
|
|
|
So, it happened to you too ?!
|
|
|
|
|
toxcct wrote: So, it happened to you too ?!
What?
Honestly... , today several things happened to me.
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.
|
|
|
|
|
you too, you had to remove your html in your sig ?!
|
|
|
|
|
The compiler is too stupid?
how can you say that when you don't even understand the whole logic of the language ? the proof is the large amount of "stupid" questions you flood here.
what happends if you declare you private vi member as a vector<int> instead of a vector<int>& ?
and are you sure your sample is correct ? didn't you declare you member const either ?
|
|
|
|
|
|
I have toolbar resource having id IDR_FORMAT_TOOLBAR
there is button on toolbar having id ID_LINK_BUTTON
I want to enable this button in some function call
please help me for this...
Chetan
|
|
|
|
|
What about sending the TB_ENABLEBUTTON message http://msdn2.microsoft.com/en-us/library/bb787311.aspx[^]?
for instance:
SendMessage( hWndToolbar, TB_ENABLEBUTTON, ID_LINK_BUTTON, MAKELONG (TRUE, 0));
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.
|
|
|
|
|
you need to handle ON_UPDATE_COMMAND_UI.
|
|
|
|
|
m_YourTB.EnableButton(ID_LINK_BUTTON, TRUE);
Regards,
Paresh.
|
|
|
|
|
When I call SetNewView, it's ok ,and the new formview (A) can receive message. But then I press a button in the view, and it called SetNewView to change to another formview (B), it looks ok, but B can't receive its messages, instead A receives, also, A's buttons will appear when I click on that area.
Here is how to do with CViews instead of CFormViews
http://msdn2.microsoft.com/en-us/library/s199bks0(VS.80).aspx#vcconswitchingfunctiona4[^]
BOOL CMyAlbumEditorApp::InitInstance()
{
#ifdef _AFXDLL
Enable3dControls();
#else
Enable3dControlsStatic();
#endif
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings();
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMyAlbumEditorDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CMyAlbumEditorView));
AddDocTemplate(pDocTemplate);
EnableShellOpen();
RegisterShellFileTypes(TRUE);
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (!ProcessShellCommand(cmdInfo))
return FALSE;
InitViews();
SetNewView(m_pStartView);
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
void CMyAlbumEditorApp::InitViews()
{
m_pNativeView = ((CFrameWnd*)m_pMainWnd)->GetActiveView();
CDocument* pCurrentDoc = ((CFrameWnd*)m_pMainWnd)->GetActiveDocument();
CCreateContext newContext;
UINT viewID;
CRect rect(0, 0, 0, 0);
m_pStartView = (CView*) new CStartForm;
newContext.m_pNewDocTemplate = NULL;
newContext.m_pLastView = NULL;
newContext.m_pCurrentFrame = NULL;
newContext.m_pCurrentDoc = pCurrentDoc;
viewID = AFX_IDW_PANE_FIRST;
m_pStartView->Create(NULL, "StartFormViewName", WS_CHILD, rect, m_pMainWnd, viewID, &newContext);
m_pStartView->SendMessage(WM_INITIALUPDATE, 0, 0);
m_pAlbumPropertyView = (CView*) new CAlbumPropertyForm;
newContext.m_pNewViewClass = NULL;
newContext.m_pNewDocTemplate = NULL;
newContext.m_pLastView = NULL;
newContext.m_pCurrentFrame = NULL;
newContext.m_pCurrentDoc = pCurrentDoc;
viewID = AFX_IDW_PANE_FIRST;
m_pAlbumPropertyView->Create(NULL, "AlbumPropertyFormViewName", WS_CHILD, rect, m_pMainWnd, viewID, &newContext);
m_pAlbumPropertyView->SendMessage(WM_INITIALUPDATE, 0, 0);
}
void CMyAlbumEditorApp::SetNewView(CView *pNV)
{
#ifndef _WIN32
::SetWindowWord(m_pNativeView->m_hWnd, GWW_ID, ::GetWindowWord(pNV->m_hWnd, GWW_ID));
#else
::SetWindowLong(m_pNativeView->m_hWnd, GWL_ID, ::GetWindowLong(pNV->m_hWnd, GWL_ID));
#endif
((CFrameWnd*) m_pMainWnd)->SetActiveView(pNV);
((CFrameWnd*) m_pMainWnd)->RecalcLayout();
pNV->ShowWindow(SW_SHOW);
}
modified on Tuesday, December 04, 2007 9:25:01 AM
|
|
|
|
|
If the area is cover by the previous formview, then messages in that area is handled by the previous formview, otherwise, it receives the message.
How strange! Why?
|
|
|
|
|