|
It's quite a mixture. I'm developing an operating system, so haven't added most of the standard definitions. But based upon the #defines it appears to be doing pretty much the same thing as the code snippet I posted. Should it theoretically work? Thanks for the link though, I'm looking through it now; it should be helpful
|
|
|
|
|
Computafreak wrote: But based upon the #defines it appears to be doing pretty much the same thing as the code snippet I posted.
(Presuming you mean va_args) yes, it will be - it's all just stack hackery, which is more dependent on the compiler you're using and hte way it lays out parameters than the OS or anything else really.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
That really helps. I've still got one or two problems, but I'll work through those on my own. Thank you
|
|
|
|
|
I know it doesnt answer all your issues - but maybe you can glean something useful from this :- http://www.codeproject.com/KB/library/ssaxpipe.aspx
'g'
|
|
|
|
|
hiii..i am trying to implement huffman coding for compressing text files...here i have to write bits of variable length into a file...but i am not able to do so...please help...
|
|
|
|
|
krish_amrita wrote: please help...
That will be very difficul since you didn't provide any useful information... What is a bit of variable lenght ?
|
|
|
|
|
Hi,
that is not beginner's stuff.
I did it once, long ago; you need to come up with a way to represent bit strings of limited length.
Here is one way of doing it:
imagine a struct "BITPATTERN" containing:
- int value; // holding up to 32 bits (right-aligned)
- int signif; // holding how many bits of value are significant.
Now implement a CONCAT(BITPATTERN a, BITPATTERN b) function that appends b to a.
The easiest way is by implementing a for loop, iterating over all the bits of b by:
- left-shifting a.value
- incrementing a.signif
- testing one bit of b.value
- if that bit is non-zero incrementing a.value
In addition one has to deal with overflows, i.e. data is not allowed to get lost in a.value while
shifting; one approach is to test for a.signif==8 and store a.value somewhere (to a file), clear it, and reset a.signif inside the CONCAT loop.
Finally, when all concatenations are done, some data may be left in a.value; so some extra zero bits should be concatenated until a.signif becomes 8 and everything gets flushed out.
BTW: you could do similar things using strings containing "0" and "1"; that is slightly easier to code, but far worse as performance goes; and the highest-performance implementations would not have a loop over the significant bits in b, they would use table lookups.
PS: I would expect some implementations to be available on the internet (and a fraction of them to be correct); make Google your friend.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Does this[^] help?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
#pragma once
using namespace std::tr1::function;
template<class _Fty>
class CDelegate : public function<_Fty>
{
public:
explicit CDelegate()
{
this->_Reset();
}
CDelegate(const _Myt& _Right)
{
this->_Reset((const _Mybase&)_Right);
}
//How to write here?
//operator()(****) //many parameters
//{
// m_funcs[0](****); //many parameters
// m_funcs[1](****); //many parameters
//}
~CDelegate()
{
this->_Tidy();
}
protected:
function<_Fty> m_funcs[2];
//reference_wrapper
};
|
|
|
|
|
That's the 'perfect forwarding' problem[^], that will only be solved well with the introduction of rvalue references in C++0x.
I would suggest you take a look at the implementation of Boost.Signals[^] - that does exactly what you're trying to implement (by which I mean the delegate concept).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello everyone,
Thanks a million for all the help you have all provided so far.
I would like to use the CTabCtrl. All the searches and examples I have been through in order for me to use it I have to create a TestTabCtrl class that is derived from CTabCtrl class and create a CPropertyPage class.
Please could someone confirm this for me or have I missed on other ways.
Thanks a million.
|
|
|
|
|
My english is pool, I can't explain for english. so I put code to you!
class CProperty1Dlg : public CDialog
{
// Construction
public:
CProperty1Dlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CProperty1Dlg)
enum { IDD = IDD_PROPERTY1_DIALOG };
CButton m_button2;
CButton m_button1;
CTabCtrl m_tab;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CProperty1Dlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CProperty1Dlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CProperty1Dlg::CProperty1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CProperty1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CProperty1Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CProperty1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProperty1Dlg)
DDX_Control(pDX, IDC_BUTTON2, m_button2);
DDX_Control(pDX, IDC_BUTTON1, m_button1);
DDX_Control(pDX, IDC_TAB1, m_tab);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CProperty1Dlg, CDialog)
//{{AFX_MSG_MAP(CProperty1Dlg)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CProperty1Dlg message handlers
BOOL CProperty1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_tab.InsertItem( 0, _T("Tab1") );
m_tab.InsertItem( 1, _T("Tab2") );
m_button2.ShowWindow( SW_HIDE );
return TRUE; // return TRUE unless you set the focus to a control
}
void CProperty1Dlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int sel = m_tab.GetCurSel();
switch(sel)
{
case 0:
m_button1.ShowWindow( SW_SHOW );
m_button2.ShowWindow( SW_HIDE );
break;
case 1:
m_button2.ShowWindow( SW_SHOW );
m_button1.ShowWindow( SW_HIDE );
break;
}
*pResult = 0;
}
|
|
|
|
|
|
Hello,
I have a CRichEditCtrl box on a CMDIChildWnd. When I move the mouse over this edit box its cursor changes to caret pointer indicating that the box is there. This CMDIChildWnd is made by Create()of CMDIChildWNd
Now when I make a Child window by CreateNewChild() and the add CRichEditCTrl on the childwindow the edit box is seen but when I move the mouse cursor on the edit box the cursor doesnt change to caret pointer .
What is the difference or what must be the problem in making child
windows in diff ways?
Pritha
|
|
|
|
|
how to create 2 state hover button or many state?!!
can one tell me
|
|
|
|
|
If you have another question, click on the "new question" link - but read the "how to get answers" post at the top first. It makes things better for you and us.
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
hi
Can you help in asking the question?!
|
|
|
|
|
I'll try - when you post it as a new question, so other people can try to help / learn from the answers.
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
I sent you the question
If you rewrite it in your own words
thanks
|
|
|
|
|
Hello,
i managed to rotate a rectangle 45 degrees. Now i have an picture that i need to map to this reversed rectangle. I heard there is an inverse mapping way. Something about u and v. I am not familiar with it. Can someone tell me how to use this?
thanks
|
|
|
|
|
You've set yourself quite a difficult task. There isn't a normal windows "draw a bitmap using these four arbitrary corners" function.
The nearest I can find is: Graphics::DrawImage, part of the GDI+ library. But it will take some learning to be able to use it from scratch.
Good luck,
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Luc Pattyn answered this question here: http://www.codeproject.com/script/Forums/View.aspx?fid=326859&select=2993859#xx2993859xx
|
|
|
|
|
Recently, I download a bunch of sample C++ programs from the URL: http://msdn.microsoft.com/en-us/library/7zx6z2e4.aspx. Unfortunately, I have been unable to build any of them. When I open up the project file and click build, I get the following output from the build:
1>------ Skipped Build: Project: Cube ------
1>
========== Build: 0 succeeded or up-to-date, 0 failed, 1 skipped ==========
When I try compiling just one of the sample programs, I get the message:
Operation could not be completed. Unspecified Error
This message appears in a “bomb box”. I am wondering if I am doing something wrong, or are these projects just bad? Please help.
Thanks
Bob
|
|
|
|
|
BobInNJ wrote: When I open up the project file...
Is that the same as opening the solution file?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
David,
Thanks for the response. Yes, when I say project file, I mean solutions file.
Bob
|
|
|
|