|
im not submitting someone else's code. i just need help. that's all.
|
|
|
|
|
Then you need to explain clearly what help; we cannot guess.
|
|
|
|
|
ok. so the binary form is stored in the string. and the i will make a for loop that will count the number of 1's in the binary form of each entered minterms. my problems is how do I group together the minterms with the same number of 1's cause i need to compare 2 different groups later.
|
|
|
|
|
I've created a new dialog in my MFC dialog based application. the new dialog contains 5 control buttons.
the following happens and I don't understand why?
(buttonX is any button).
1. click on buttonX. (result ok, OnBnClicked message is sent)
2. click on on any place of the application, but not on the dialog. (removing focus from dialog)
3. click again on buttonX (FAILED, OnBnClicked message is NOT sent). but if instead I click on any other button in the dialog (result ok, OnBnClicked message is sent).
and when I do:
1. ...
2. ...
3. click on the dialog area just to set focus on the dialog again
4. click again on buttonX. (result ok, OnBnClicked message is sent)
(*) I need to do step 3 only if I want to click again on the buttonX! why??
I think it related to SetFocus() but I m not sure how.
the buttons IDC are: IDC_BACK_MEDIA_PRESS_BUTTON 1180 IDC_TOOLS_LEFT_RIGHT 1024 IDC_MEDIA_FOREWARD_BUTTON 1103 IDC_MEDIA_BACKWARD_BUTTON 1104 IDC_TOOLS_HOOD_BUTTON 2346
the dialog properties is:
IDD_TOOLS_DIALOG DIALOGEX 0, 0, 51, 218 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Tools" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN PUSHBUTTON "Media &Foreward",IDC_MEDIA_FOREWARD_BUTTON,7,79,37,36,BS_MULTILINE PUSHBUTTON "&Media &BackWard",IDC_MEDIA_BACKWARD_BUTTON,7,43,37,36,BS_MULTILINE PUSHBUTTON "Back Media Press",IDC_BACK_MEDIA_PRESS_BUTTON,7,127,37,36,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Hood",IDC_TOOLS_HOOD_BUTTON,7,7,37,36 PUSHBUTTON "Left Right",IDC_TOOLS_LEFT_RIGHT,7,175,37,36 END
I've tried different style like, tool windows, overlapped, popup. it happens in all the cases.
Thanks for the help.
.h
<pre>
class CToolsDlg : public CBDialog
{
DECLARE_DYNAMIC(CToolsDlg)
public:
CToolsDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CToolsDlg();
CToolTipCtrl m_ToolsTips;
// Dialog Data
enum { IDD = IDD_TOOLS_DIALOG };
protected:
virtual void OnCancel();
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CMFCButton m_HoodButton;
CMFCButton m_MediaForewardButton;
CMFCButton m_MediaBackwardButton;
CMFCButton m_LeftRightButton;
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg void OnBnClickedCancel();
afx_msg void OnBnClickedToolsHoodButton();
afx_msg void OnBnClickedMediaForewardButton();
afx_msg void OnBnClickedMediaBackwardButton();
afx_msg void OnBnClickedLeftRightButton();
afx_msg void OnBnClickedBackMediaPressButton();
};
.cpp
IMPLEMENT_DYNAMIC(CToolsDlg, CBDialog)
CToolsDlg::CToolsDlg(CWnd* pParent /*=NULL*/)
: CBDialog(CToolsDlg::IDD, pParent)
{
}
CToolsDlg::~CToolsDlg()
{
}
void CToolsDlg::DoDataExchange(CDataExchange* pDX)
{
CBDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TOOLS_HOOD_BUTTON, m_HoodButton);
DDX_Control(pDX, IDC_MEDIA_FOREWARD_BUTTON, m_MediaForewardButton);
DDX_Control(pDX, IDC_MEDIA_BACKWARD_BUTTON, m_MediaBackwardButton);
DDX_Control(pDX, IDC_TOOLS_LEFT_RIGHT, m_LeftRightButton);
}
BEGIN_MESSAGE_MAP(CToolsDlg, CBDialog)
ON_WM_CLOSE()
ON_WM_DESTROY()
ON_WM_TIMER()
ON_BN_CLICKED(IDC_TOOLS_HOOD_BUTTON, &CToolsDlg::OnBnClickedToolsHoodButton)
ON_BN_CLICKED(IDC_MEDIA_FOREWARD_BUTTON, &CToolsDlg::OnBnClickedMediaForewardButton)
ON_BN_CLICKED(IDC_MEDIA_BACKWARD_BUTTON, &CToolsDlg::OnBnClickedMediaBackwardButton)
ON_BN_CLICKED(IDC_TOOLS_LEFT_RIGHT, &CToolsDlg::OnBnClickedLeftRightButton)
ON_BN_CLICKED(IDC_BACK_MEDIA_PRESS_BUTTON, &CToolsDlg::OnBnClickedBackMediaPressButton)
END_MESSAGE_MAP()
// CToolsDlg message handlers
BOOL CToolsDlg::OnInitDialog()
{
CBDialog::OnInitDialog();
// Window position
//////////////////////////////////////////////////////////////////////////
CMainFrame* mf = (CMainFrame*)AfxGetMainWnd();
RECT MFwinRect;
RECT ThiswinRect;
CWnd* fv = mf->m_wndSplitter.GetView( mf->m_wndSplitter.GetCurrentViewIndex(0,0) );
fv->GetWindowRect(&MFwinRect);
GetWindowRect(&ThiswinRect);
MoveWindow(
MFwinRect.right - (ThiswinRect.right - ThiswinRect.left) - 14, // X
MFwinRect.top + 14, // Y
(ThiswinRect.right - ThiswinRect.left), // nWidth
(ThiswinRect.bottom - ThiswinRect.top) ); // nHeight
// Set controls state
//////////////////////////////////////////////////////////////////////////
m_ToolsTips.Create(this);
m_ToolsTips.AddTool(&m_HoodButton, TOOLTIP_HOOD_BUTTON);
m_ToolsTips.AddTool(&m_MediaForewardButton, TOOLTIP_MEDIA_FOREWARD_BUTTON);
m_ToolsTips.AddTool(&m_MediaBackwardButton, TOOLTIP_MEDIA_BACKWARD_BUTTON);
m_ToolsTips.AddTool(&m_LeftRightButton, TOOLTIP_LEFT_RIGHT_BUTTON);
m_ToolsTips.SetDelayTime(1000);
m_ToolsTips.Activate(BARAK_PREFS->m_Params.m_bShowToolTips);
// Main timer loop (no need for now)
// SetTimer( 1, 1000, NULL );
return TRUE;
}
BOOL CToolsDlg::PreTranslateMessage(MSG* pMsg)
{
m_ToolsTips.RelayEvent(pMsg);
return CBDialog::PreTranslateMessage(pMsg);
}
void CToolsDlg::OnCancel()
{
// When closing the window, destroy it and not only hide (its a floating window).
DestroyWindow();
}
void CToolsDlg::OnTimer(UINT_PTR nIDEvent)
{
CBDialog::OnTimer(nIDEvent);
}
void CToolsDlg::OnBnClickedToolsHoodButton()
{
...
}
void CToolsDlg::OnBnClickedMediaForewardButton()
{
...
}
void CToolsDlg::OnBnClickedMediaBackwardButton()
{
...
}
void CToolsDlg::OnBnClickedLeftRightButton()
{
...
}
void CToolsDlg::OnBnClickedBackMediaPressButton()
{
...
}
|
|
|
|
|
Which button is it that is doing this behavior? I don't see any button called "buttonX".
Or do all the buttons show this behavior?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hello Richard, "buttonX" applies to all buttons.
|
|
|
|
|
I have following code
int nSize = 100;
unsigned char* pBuffer;
pBuffer = new unsigned char(nSize);
and I tried to clean it by
delete[] pBuffer;
but seems not working ... I have done wrong ?
modified 2-Oct-14 8:50am.
|
|
|
|
|
I know what: I replaced "(" by "[" in
pBuffer = new unsigned char(nSize);
ex
pBuffer = new unsigned char[nSize];
|
|
|
|
|
I found the following program that count the number of words within a phrase but I don't understand the
initial code defined on the int main :
" int argc,const char * argv[]
just want learn. thanks
--------------------------------------
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
// ask the user to enter a string
cout << "Enter a string: ";
// save the string entered by the user
string input;
getline(cin, input);
int numberOfWords = 0;
// loop through the input and count all the spaces
int inputLen = (int)input.length();
for (int i=0; i<inputLen; i++) {
char current = input.at(i);
if (isspace(current)) {
numberOfWords++;
}
}
// in case there were words, and not empty string, remember that there's always
// one space less than the actual number of words
if (numberOfWords > 0) {
numberOfWords++;
}
// print the number of words
cout << "\nNumber of words = " << numberOfWords << endl;;
return 0;
}
|
|
|
|
|
argc = arg count
*argv[] = an array of argc number of strings.
Consider the following program:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int i;
for(i=0; i<argc; i++)
printf("Argument index %d: %s\n", i, argv[i]);
return 0;
}
When I call the program from the command line like so:
argcdemo arg1 arg2 -someFlag -somethingElse
I get the following output:
Argument index 0: argcdemo
Argument index 1: arg1
Argument index 2: arg2
Argument index 3: -someFlag
Argument index 4: -somethingElse
So as you can see, the first one takes the name of the program as invoked, the others get a string from the command line, where each string is separated by a space. Or more simply, the argc will always be at least 1,since you have to specify the name of the program to run. Any subsequent arguments will increment argc and have their values added to the argv array.
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
Google is your friend. See for instance: "argc and argv"[^].
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Hi,
Is it possible to bind the "this" pointer to make a callback into a non-static class member function (c++98, no boost).
I don't think the "this" pointer is passed directly as a parameter to the function?
typedef void (*CallBackType)(void);
...
obj->SetCallback(std::bind1st(&MyClass::CallBackFunc, this));
|
|
|
|
|
No, it is not possible (at least as far as I know). From bind1st at C++ Reference : Return function object with first parameter bound
This function constructs an unary function object from the binary function object op by binding its first parameter to the fixed value x.
A method taking one argument is not exactly a binary function.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
You could use bind1st if CallBackFunc took one parameter:
void CallBackFunc(int) { ... }
...
obj->SetCallback(std::bind1st(std::mem_fun(&MyClass::CallBackFunc), this));
Since it takes nothing, you may have to write your own function template that takes a callable and a pointer that returns a small function object that stores the callable and the pointer as members and invokes them with operator(): as always, by refusing to use boost you're forcing yourself to reimplement parts of it.
|
|
|
|
|
I need to capture Desktop and Filter with some active windows
Or
I need to capture only Desktop i.e Desktop Background and Icons if some other active windows are maximized.
Please help me to do this. In my project this is main concept. Thanks to spend your valuable times for this.
Thanks & Regards
Narmadha
|
|
|
|
|
narmadha_s wrote: I need to capture Desktop and Filter with some active windows You need to explain better what you mean by this. What exactly are you trying to capture, and what do you want to do with it?
|
|
|
|
|
I want to capture total desktop. In that i have to filter my application window only. i.e Have to capture entire desktop with some restrictions. This is for like call center application.
Without my application window, i have to capture entire desktop. But my application will be visible and active window on desktop. Please kindle help me... Thanks to spend your valuable time for this.....
Regards,
Narmadha
|
|
|
|
|
|
If you already know how to initiate a "print screen" command to capture windows, then you could precede that with something like the following to minimize all windows first:
CoInitialize(NULL);
IShellDispatch4 *pShellDisp = NULL;
HRESULT sc = CoCreateInstance(CLSID_Shell, NULL, CLSCTX_SERVER, IID_IDispatch, (LPVOID *) &pShellDisp);
sc = pShellDisp->ToggleDesktop();
sc = pShellDisp->ToggleDesktop();
pShellDisp->Release();
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Thank you for the reply...
But i have to capture without minimize the windows. Actually, My requirement is,
I have to capture Entire desktop without my application window. My application will be visible and active window on desktop. Please do you have any idea on this help me...
Regards,
Narmadha
|
|
|
|
|
narmadha_s wrote: I have to capture Entire desktop without my application window. So then minimize just your app and then capture the desktop.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
First. Minimize All running apps. Run the code below.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
keybd_event(VK_MENU, 0, 0, 0); keybd_event(VK_SNAPSHOT, 0, 0, 0);
keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0); keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
return 0;
}
|
|
|
|
|
How can I change LVS_ALIGNLEFT by LVS_ALIGNTOP (of an CListCtrl) at runtime ? The list has LVS_ICON style already ...
Thank you.
|
|
|
|
|
|
What you are looking for is the funtion CWnd::ModifyStyle.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|