|
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
|
|
|
|
|
Hi guys. I hope someone can help beacuse I am new at MFC and I am running out of time.
I need to write a MFC program which will simply read some text file and display it. The other thing is that I need to add a search option to the program. When you search some word, and if it is found in the displayed text it should be displayed in different color.
I have been fighting with this for a week and still no success. Can someone at least tell me how to start on the right track, wich base class should i use, how should I display the text, and finally, how to color the words that have been found?????
Any links or code samples would really help.......
thanx
|
|
|
|
|
Try using CFileDialog and search it up on MSDN
|
|
|
|
|
I used CFileDialog just to open the file. And I managed to display the text with DrawText function within a rectangule of variable dimensions. But how can I display let's say one word in yellow color and one word in red? I only managed to display whole text in one color.....
|
|
|
|
|
Are you using a CEdit editbox? I don't think it's possible to highlight in different colors in a CEdit. I haven't worked in MFC a lot, but you can try Rich Edit and see if there's a function in there.
|
|
|
|
|
Call TextOut or DrawText twice, with a call to SetTextColor before painting each of the two words.
|
|
|
|
|
the problem is that drawtext uses CRect in it. So i would than have to determine a exact rectangule position each time I want to change the color of the text. I don't think that this is a good solution.
Any other idea? if it is easier, do you know how to draw a rectangle over the word you searched for in the text?
|
|
|
|
|
I think there's no easier way, except maybe using CRichEditCtrl.
|
|
|
|
|
You can generate a project to do this in Visual Studio.
Almost all point and click (a tiny bit of typing).
Use the Add new project dialog -
Choose MFC application, give it a name
Do NOT choose Unicode option
Choose doc/view support and pick SDI or MDI.
Change the app file types/extensions to "Text", "txt", etc.
In the generated classes tab, change the view base class to CEditView
Build the project - you have a working text editor.
Edit the menu resource and add a "Find..." item to the "Edit" popup (give it the id "ID_EDIT_FIND")
Build the project - you now have text search capability.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I tried that, but the problem is that when i press the button search and let's say that searched word was "mfc", then in one click all mfc should be highlighted in the whole text.
I hope you understood what I need to achive. Me and my english language......
thanx
|
|
|
|
|
I thought so, but I thought I'd throw that out there just in case.
As others have mentioned, you'll need to render the text yourself or use a richedit control.
Either way you'll need to search the text and keep track of where the found items are.
If you use a richedit control, the control will do the rendering for you - all you need to do is
change the text color of all the found items.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|