I want to use a simple input box in vc++ mfc. I did created a dialog called IDD_DIALOG1, and added a text box. I added a public variable for the input box and created a class call CInputDlg. Now I use the following code but I face with error:
CInputDlg dialog;
if (dialog.DoModal() == IDOK)
{
m[nodeTemp][i] = weight;
}
the error is:
Error 2 error C2065: 'CInputDlg' : undeclared identifier c:\users\omid\documents\visual studio 2008\projects\shortest path\shortest path\shortest pathdlg.cpp 294
what's the problem? can anyone help me please?
At the top of the file containing this code (it looks like you've named it shortest pathdlg.cpp):
CInputDlg dialog;
if (dialog.DoModal() == IDOK)
{
m[nodeTemp][i] = weight;
}
You need to add an #include statement that tells the compiler you'll be using things defined in a different source code file. In this case, you need to add the header file that defines the class CInputDlg. Presumably that file is called InputDlg.h. If so, you can simply add the following line:
#include "InputDlg.h"
For more information, please read this MSDN article about #include Directives in C++
Hi i think you not include h file for it. Show yours includes in shortest pathdlg.cpp
Related
The tl;dr How do I open a window in Juce to display a plugin Editor?
I am following the Juce AudioProcessGraph tutorial at https://docs.juce.com/master/tutorial_audio_processor_graph.html which shows how to dynamically load AudioProcessor objects.
I would like to open their GUIs as they're loaded. This could be in separate windows or in the window that's got the slots for the graph.
I've tried creating a AudioProcessorEditor, but I'm at a loss on how to tell it to open.
Edit to add: What I've tried so far:
I've downloaded the code from the Tutorial: Cascading plug-in effects from https://docs.juce.com/master/tutorial_audio_processor_graph.html
I've also used ProJucer to create a new plugin. I've put the new plugin's files into the tutorial's files and used ProJucer to add PluginEditor.cpp and PluginEditor.h to the tutorial project.
I've changed the PluginEditor.h so the private class member audioProcessor is of type ProcessorBase&. And made ProcessorBase& the expected type for the data passed to the constructor.
In the tutorial code, in the header file, I've changed the ProcessorBase class so that the methods hasEditor() and createEditor() are just declarations and then modified main.cpp as follows:
#include "PluginEditor.h"
#include <iostream>
//=======================================================
juce::AudioProcessorEditor* ProcessorBase::createEditor()
{
std::cout "asking for an editor\n";
return new NewProjectAudioProcessorEditor (*this);
}
bool ProcessorBase::hasEditor() const
{ return true; }
In the included header, in the TutorialProcessor class, in the updateGraph() method, under the if (hasChanged), I've added slot->getProcessor()->createEditorIfNeeded (); on line 387-ish.
I can tell from my cout that createEditor() is being called and know that the constructor for the editor is running, but no window opens.
How do I tell it to open a window?
The code compiles and runs, but no window opens.
I've implemented a Property Sheet and several Property Pages that are called from the Main Menu from the MainFrame.cpp spawned from my issue here:
MFC MDI Designing user preferences dialog GUI layout functionality
The code I landed on was:
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx)
Other messages...
ON_COMMAND(ID_SETTINGS_DIALOG, OnSettingsTools)
Other messages...
END_MESSAGE_MAP()
void CMainFrame::OnSettingsTools()
{
SettingsSheet SettingsSheet(L"Application Settings");
CSettingsPowerUser m_PowerUser;
CSettingsReset m_Reset;
CSettingsToolbars m_Toolbars;
CSettingsUserWarnings m_UserWarnings;
SettingsSheet.AddPage(&m_PowerUser);
SettingsSheet.AddPage(&m_Reset);
SettingsSheet.AddPage(&m_Toolbars);
SettingsSheet.AddPage(&m_UserWarnings);
//SetLook(CMFCPropertySheet::PropSheetLook_OneNoteTabs);
SettingsSheet.DoModal();
}
Yielding:
I have included in MainFrame.h
#include <afxpropertysheet.h>
The property sheet is using CMFCPropertySheet in both the .cpp & .h as shown here in its .h file:
class SettingsSheet : public CMFCPropertySheet
{
DECLARE_DYNAMIC(SettingsSheet)
public:
SettingsSheet(UINT nIDCaption, CWnd* pParentWnd = nullptr, UINT iSelectPage = 0);
SettingsSheet(LPCTSTR pszCaption, CWnd* pParentWnd = nullptr, UINT iSelectPage = 0);
virtual ~SettingsSheet();
protected:
DECLARE_MESSAGE_MAP()
};
So what the issue here is, you can see that I had to comment out the SetLook(CMFCPropertySheet::PropSheetLook_OneNoteTabs); because I get an error that says SetLook identifier not found C3861.
If I hover inside the MainForm.h and right click the #include <afxpropertysheet.h> the file opens right up in the IDE and if I search for SetLook it most certainly can find it in the public section of the function.
So I've seen multiple code examples that use that SetLook and one of the tutorials I looked at used it and it works fine as I'm using VS2017.
I realize what a "not found is", but I'm at a loss as to why it's a problem here. It is the only error I am having now and I would like to use that functionality.
Thoughts on what may be going on here?
Update:
Following Dxiv's advice I changed the code to:
SettingsSheet.SetLook(CMFCPropertySheet::PropSheetLook_OneNoteTabs);
It now compiles and runs, but have some odd results, it only shows one property page, and all the rest are AWOL.
I have figured out what the issue was; when I created the dialogs I used the base class of:
CPropertyPage
instead of:
CMFCPropertyPage
I had set the sheet to:
CMFCPropertySheet
and assumed it carried down since it compiled and displayed the tab view correctly, but failed on the other SetLook property options.
Once I adjusted all the dialogs to CMFCPropertyPage, the SetLook started working immediately. So I consider this issue CLOSED.
I'm trying to find out if a window belongs to the current virtual desktop.
I found the VirtualDesktopManager class form the winapi, but even though it is supposed to be in the "shobjidl.h" header according to here, when I compile the code it throws this error:
85:5: error: 'VirtualDesktopManager' was not declared in this scope
important piece of my code:
#include <shobjidl.h>
...
BOOL is_on_current_desktop = FALSE;
VirtualDesktopManager g_pvdm;
g_pvdm.IsWindowOnCurrentVirtualDesktop(hwnd, &is_on_current_desktop); // hwnd is a window handle acquired previously
g_pvdm.Release();
How could I make this work?
Apparently this interface was not included in the "shobjidl.h" header in mingw64 which I was using, running it in Visual Studio it finds it. So the issue was in the header.
I needed to get the id of the focused item from a listview using a handle:
int selected = (int)SendMessage(hWnd, LVM_GETSELECTIONMARK, 0, 0);
However, I get an error that LVM_GETSELECTIONMARK was not declared in this scope? Is there something wrong with my library because the macro ListView_GetSelectionMark(hWnd) does not exist either.
Also, I did include commctrl.h in the header.
Thank you.
Add these lines to your project. For some reason these are missing from the Commcrtl.h included with Codeblocks IDE.
#define LVM_GETSELECTIONMARK (LVM_FIRST+66)
#define ListView_GetSelectionMark(w) (INT)SNDMSG((w),LVM_GETSELECTIONMARK,0,0)
I'm very much a C++ newbie, so please bear with me.
This line of code which resides within a function:
CWnd* pWnd = CWnd::FindWindow("Shell_TrayWnd", "");
CWnd is coming up as "undefined". I know I need to define it in the global scope, but how? What header do I need to include to use this class? Project is MFC.
Using VS 2010.
Here's how to solve this problem independently.
First, Google for "cwnd"
Second, click the first link.
Third, read the page
Requirements
Header: afxwin.h