|
thanks george,
lets circulate this idea to all the members such that, this will become a habbit and practise.
this idea is for a good and convinient maintenence of the forum.
|
|
|
|
|
You are welcome chandu004,
I think even for old members, they may not fully be aware of this habit. If in CodeProject newsletter or something, this message could be delivered, it will be great!
Changing topic to *solved* only takes poster one minute, and will benefit a lot of people who have similar issues.
regards,
George
|
|
|
|
|
chandu004 wrote: i request all the members to follow this idea.
I like it!!!
Russell
|
|
|
|
|
Hi,
I just switched to Visual Studio 2005 from VC++ 6.0 and I usually added the dialog overrides like OnOk, OnInitDialog etc. to my file from a wizard. I can't find any way to do this in 2005.
I can see the message events and control events in the properties editor when my resource is displayed but not the overrides to OnInitDialog etc.
Is there a wizard for this?
Thanks
|
|
|
|
|
You need to use classview for that.
Refer this[^] article.
Prasad
MS MVP - VC++
|
|
|
|
|
Thanks Prasad but I saw the "Project -> Add Function" menu when in class view but it does not give you a list of the CDialog functions.
Of course I can add the function overrides manually but it was a nice time saver.
|
|
|
|
|
al2500 wrote: Of course I can add the function overrides manually
No, when I said, "Use class view", then it meant, right click class, go to properties, and use properties window to override the functions. You may not feel comfortable initially, due to use ot previous versions of VS.
Read, article mentioned in my previous post. It should give you some idea.
Prasad
MS MVP - VC++
|
|
|
|
|
AS prasad said, right-click the class and select properties. You can also get to this properties display if your cursor is inside the source for the class definition. Once you have the properties windows, look at the buttons along the top of the properties page. There are ones for Overrides, Message Handlers and Events. Most of the old VC6 things are listed under one of those three buttons.
J
|
|
|
|
|
hello to every one..
i need to know how to create a dialog box with controls at runtime?
plz help me..
vikram..
|
|
|
|
|
CreateDialogIndirect API may help you.
Have a look here[^]
- NS -
|
|
|
|
|
In VC 2005, I create the dialog project, and add the radio button, and then set the dialog background with picture.
The functions like below:
CTestBrushDlgDlg::CTestBrushDlgDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestBrushDlgDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_nullBrush.CreateStockObject(NULL_BRUSH);
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BACKUP) ;
m_brush.CreatePatternBrush(&bitmap);
}
HBRUSH CTestBrushDlgDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if (nCtlColor == CTLCOLOR_STATIC )
{
pDC->SetBkMode(TRANSPARENT);
return m_nullBrush;
}
return (HBRUSH)(m_brush.m_hObject);
}
1. when setting "Character Set" of dialog project property to "Use Unicode Character Set", this radio background shows the picture, not transparent.
2. when setting "Character Set" of dialog project property to "Use Multi-Byte Character Set", this radio background is transparent,it works fine.
How to resolve problem 1.
Thanks,
Recky
fanasus@gmail.com
-- modified at 1:56 Friday 31st August, 2007
|
|
|
|
|
I want to get the WiFi information (eg. signal strength) from code (eg. C++, C#).
OS may be XP, CE5.0 or above.
I know it can be related to ndisuio.
Where can I get more coding information?
Thanks!
|
|
|
|
|
void CIODlg::OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_Edit_PeriodCount=pNMUpDown->iPos;//or m_Edit_PeriodCount=m_Spin_Count.GetPos32();
m_Slider_Data[0].SetPos(m_Edit_PeriodCount);
UpdateData(FALSE);
*pResult = 0;
}
m_Edit_Period is control int variable of edit box.
the value does change on the click of spin control, but somehow the action seems to "lag" by one click.
for example, the initialized value in edit box is 0;
i click the spin up, nothing change,
i click UP the second time, the value change to 1, if i keep clicking up, no problem.
if i then click down once,the value still increase;
if i click down for the second time, the value start to decrease.
so the action seems to lag by one click.
What's the cause?
thx
|
|
|
|
|
If the problem is a numeric problem try to debug the project putting the breakpoint where the counter is increased (and look to the stack).
Elseway it can also be a refresh/redraw problem.
Hope helps
Russell
|
|
|
|
|
the quertion is that please cout a map like this
1 3 6
2 5 8
4 7 9
and my code is this:where is my wrong, and can you give me a full code ?
#include <iostream>
using namespace std;
void mm(int n,int aa[n]);
main()
{
cin>>n;
int sum=0 ;
int aa[n];
for(m=1;m<=n;m++)
{
sum=sum+n;
aa[m-1]=sum;
};
mm(n,aa[n]);
return 0;
};
void mm(int n,int aa[n])
{
int bb[n];
for(k=0;k<=n-1;k++)
{
if (k=n-1)
{
bb[n-1]=aa[n-1]+n-1;
cout<< aa[n-1]+n-1<
|
|
|
|
|
I really tryed to understand your code...but it is impossible!
Please, do not use names to function or to variable like aa bb n m mm k , but use something like sum that let the code be more readable:
youbo wrote: cin>>n;
What this used for?
What is your output?
be more detailed, ... the reason is that no-one will compile your code, everyone will try to find the error wimply reading it, so, let it be easy.
Russell
|
|
|
|
|
I am trying to create a dialog box which reads input from a *.txt file with the following format:
Item1 0
Item2 0
Item3 1
Item4 0
And the idea is that for each line a check box is created, where the caption is the word on the line and its initial status is either off (0) or on (1).
I have spent about 20 hours trying to develop a solution and have come up pretty much empty so far. Could someone please assist?
|
|
|
|
|
What's giving you trouble? Reading the file or creating a checkbox dynamically?
Are you using MFC?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How does a caption be on or off?
One simple option - use the spanky shiny "new" grid control here on CP - I've used C. Maunder's original one.
You don;t them have to dynamically construct the dialog box, and just fill in N rows with your captions. You could even use checkbox cells to be On / Off.
Iain.
|
|
|
|
|
Here's some MFC code. I hope this helps....I left it to you to layout the controls and provide them an ID...
(The sample assumes it's in a CDialog derived class, using "this" as the parent of the checkbox control(s))
TRY
{
CStdioFile file(_T("c:\\dialogitem.txt"), CFile::modeRead | CFile::shareDenyNone);
CString LineStr;
while (file.ReadString(LineStr))
{
int i = 0;
CString CaptionStr = LineStr.Tokenize(_T(" "), i);
CString CheckStr = LineStr.Tokenize(_T(" "), i);
int CheckState = (_tstol(CheckStr) == 0) ? BST_UNCHECKED : BST_CHECKED;
CRect CtrlRect(...);
UINT CtrlID = ...;
CButton NewCheckBox;
NewCheckBox.Create(CaptionStr, WS_VISIBLE | WS_CHILD | BS_CHECKBOX, CtrlRect, this, CtrlID);
NewCheckBox.SetCheck(CheckState);
NewCheckBox.Detach();
}
file.Close();
}
CATCH( CFileException, e )
{
}
END_CATCH
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello I can't figure this out . Here is my class and functions
For some reason the OnUpdate function is only printing the first column
and not the other 1
What am I doing wrong?? thx
// viewcView.h : interface of the CViewcView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_VIEWCVIEW_H__C9A435B3_A707_486C_820E_191CD7126DDD__INCLUDED_)
#define AFX_VIEWCVIEW_H__C9A435B3_A707_486C_820E_191CD7126DDD__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CViewcView : public CView
{
protected: // create from serialization only
CViewcView();
DECLARE_DYNCREATE(CViewcView)
CListCtrl m_List;
// Attributes
public:
CViewcDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CViewcView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnInitialUpdate(); // first time after construct
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CViewcView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CViewcView)
// NOTE - the ClassWizard will add and remove member functions here.
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in viewcView.cpp
inline CViewcDoc* CViewcView::GetDocument()
{ return (CViewcDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_VIEWCVIEW_H__C9A435B3_A707_486C_820E_191CD7126DDD__INCLUDED_)
// viewcView.cpp : implementation of the CViewcView class
//
#include "stdafx.h"
#include "viewc.h"
#include "viewcDoc.h"
#include "viewcView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CViewcView
IMPLEMENT_DYNCREATE(CViewcView, CView)
BEGIN_MESSAGE_MAP(CViewcView, CView)
//{{AFX_MSG_MAP(CViewcView)
// NOTE - the ClassWizard will add and remove mapping macros here.
ON_WM_CREATE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CViewcView construction/destruction
CViewcView::CViewcView()
{
// TODO: add construction code here
}
CViewcView::~CViewcView()
{
}
int CViewcView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rect;
GetClientRect(rect);
VERIFY (m_List.Create (WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SINGLESEL,
CRect (0, 0, 0, 0), this, 1));
return 0;
}
void CViewcView::OnInitialUpdate()
{
CView::OnInitialUpdate();
VERIFY (-1 != m_List.InsertColumn (0, "Part Number", LVCFMT_LEFT, 100));
VERIFY (-1 != m_List.InsertColumn (1, "Part Desc", LVCFMT_LEFT, 100));
}
void CViewcView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
CView::OnUpdate (pSender, lHint, pHint);
int nItem = m_List.InsertItem(0, "column0");
m_List.SetItemText(nItem, 1, "column1");
}
BOOL CViewcView::PreCreateWindow(CREATESTRUCT& cs)
{
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CViewcView drawing
void CViewcView::OnDraw(CDC* pDC)
{
CViewcDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CViewcView printing
BOOL CViewcView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CViewcView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CViewcView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CViewcView diagnostics
#ifdef _DEBUG
void CViewcView::AssertValid() const
{
CView::AssertValid();
}
void CViewcView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CViewcDoc* CViewcView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CViewcDoc)));
return (CViewcDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CViewcView message handlers
void CViewcView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
m_List.MoveWindow (0, 0, cx, cy);
}
-- modified at 18:26 Thursday 30th August, 2007
|
|
|
|
|
shiftwik wrote: For some reason the OnUpdate function is only printing the first column
and not the other 2
You've only created two columns, not three.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Why is the view derived from CView instead of CListView ? I would not even bother trying to figure out what is wrong (which is a combination of creating the control dynamically and the OnSize() method) until I at least did that.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
It has been quite a while. I have a task to identify a calling Windows' batch script's name and its location. Basically, the batch script calls/spawns my C++ executable as a parent process and I failed to identify the parent. I can identify a number of different calling processes using NtQueryInformationProcess(), but failed to do so to the batch script. The main reason is that the batch process is shown as cmd.exe not a real script name. Any idea?
Thanks a lot for the help.
Jack
|
|
|
|
|
hi,
i need to assign port in a TDI server code.
how can i do this ?
I know i have use TdiBuildListen function to assign port, but i have not been able to assign properly.
Can anyone help me in this regards ?
With thanks in advance,
barun
barun
|
|
|
|
|