|
This would be better placed in the C / C++ / MFC forum[^].
There is no class wizard support because the CFolderPickerDialog is based on Windows common dialogs which are handled a little bit different. So you must derive your class manually.
To get help with your problem you should post the relevant source code parts.
|
|
|
|
|
Hi. I wrote a code that should have graphical menu choices. But I am getting error I believe it is syntax error where it does the menu choices. Can you please help me fix it for me? It has a lot of errors I believe they are syntax. I am thinking if I fix few errors all of them will be perfect. Please post your code. Thank you so much. Here is the part of the code that I have problem.
CWindow :
{
public:
CContainedWindow m_Parent;
CWindow() :
m_Parent(this, 1){}
protected:
typedef CWindowImpl<T, TBase, TWinTraits> baseClass;
BEGIN_MSG_MAP(CWindow)
other msgs
ALT_MSG_MAP(1)
MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem)
END_MSG_MAP()
{
}
};
CWindow
{
public:
DECLARE_WND_SUPERCLASS(_T("WTL_CButtonMenu"), GetWndClassName())
CButtonMenu& operator=(HWND hWnd)
{
if (m_hWnd)
DestroyWindow();
if (::IsWindow(hWnd))
SubclassWindow(hWnd);
return *this;
}
CWindow btnMenu;
btnMenu = GetDlgItem(IDC_BTN_ABOUT);
btnMenu.AddMenuItem(IDC_MNU_ONE, "Windows");
btnMenu.AddMenuItem(IDC_MNU_TWO, "Template");
btnMenu.AddMenuItem(IDC_MNU_THREE, "", MF_SEPARATOR);
btnMenu.AddMenuItem(IDC_MNU_FOUR, "Library");
};
|
|
|
|
|
What is the error? Are you sure you can add a menu item to a button?
|
|
|
|
|
Hi eveeryone,
Can someone please look at my code and teach me where i am making mistake.
void Laptop::show()
{ Computer::show();
cout<<"weight is="<<weight<<endl;
cout<<"height is ="<<height<<endl;
cout<<"length is ="<<length<<endl;
cout<<"width is ="<<width<<endl;
}
//In this function Laptop::show is a child class fucntion which is calling Computer::show(); a base class function.but compiler gives error to use .or -> so function Computer::show(); is not called.
Orignal code is given below:
#include<iostream.h>
#include<conio.h>
class Computer
{
protected:
int wordSize;
int memorySize;
int storageSize;
int speed;
public:
Computer(){}
Computer(int,int,int,int);
void show();
};
class Laptop
{
private:
int width;
int height;
int length;
int weight;
public:
Laptop(){}
Laptop(int,int,int,int,int,int,int,int);
void show();
};
Computer::Computer(int wdSize, int memSize, int storSize ,int spee)
{
wordSize=wdSize;
memorySize=memSize;
storageSize=storSize;
speed=spee;
}
void Computer::show()
{
cout<<"Word Size :"<<wordSize<<endl;
cout<<"Memory Size: "<<memorySize<<endl;
cout<<"Storage Size"<<storageSize<<endl;
cout<<"Speed :"<<speed;
}
Laptop::Laptop(int wdSize, int memSize,int storSize, int spee,int wid, int hei , int len , int wait ):Computer(wdSize,memSize,storSize,spee);
{
width=wid;
length=len;
height=hei;
weight=wait;
}
void Laptop::show()
{ Computer::show();
cout<<"weight is="<<weight<<endl;
cout<<"height is ="<<height<<endl;
cout<<"length is ="<<length<<endl;
cout<<"width is ="<<width<<endl;
}
void main()
{
clrscr();
Computer comp(4,512,20,2);
Laptop lap(8,1024,50,2,15,19,14,2);
cout<<"Computer Specifications are"<<endl;
comp.show();
cout<<":Laptop specifications are"<<endl;
lap.show();
getch();
}
|
|
|
|
|
Your Laptop class does not inherit Computer , so you cannot call it in that way. Your definition should be:
class Laptop : Computer
{
|
|
|
|
|
Hi all,
I'm trying to use ATL(no mfc support) to develop a activex component used in IE, and I want to design UI like common windows including menu, view window and status bar, but all article I searched from web always use dialog style, no related article for my problem.
Also, I have the code generated by wizard, Within my com component, I have the code block below:
CContainedWindow m_ctlStatic;
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
CHAIN_MSG_MAP(CComControl<CUniDocCtrl>)
ALT_MSG_MAP(1)
END_MSG_MAP()
also, the OnCreate code is below:
LRESULT OnCreate(UINT , WPARAM , LPARAM , BOOL& )
{
RECT rc;
GetWindowRect(&rc);
rc.right -= rc.left;
rc.bottom -= rc.top;
rc.top = rc.left = 0;
m_ctlStatic.Create(m_hWnd, rc);
return 0;
}
My idea is to replace the
m_ctlStatic.Create(m_hWnd, rc); with my own windows create function and add menu, code is below:
m_ctlStatic.Create(m_hWnd, rc, _T("hello"), WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_AUTOVSCROLL);
HMENU hmenu;
hmenu = LoadMenu(g_hModule,MAKEINTRESOURCE(IDR_MENU1));
m_ctlStatic.SetMenu(hmenu);
It doesn't work at all, and also it jump to base method which display the "ALT 10.0" text.
how to solve this problem, thanks in advance.
|
|
|
|
|
Hello
I have an application made with VC++ that can show a lot of dialogs. Those dialogs have been defined in an RC file and contains ActiveX controls made with Visual Basic 6.
My promen is the following one:
I have compiled the application in 64 bits, and when I launch the application and it is going to show a dialog, it fails. I think this is due to there is not 64 bits runtime for VB6.
What I want it is to generate an equivalent RC file to the RC file I have but replacing the controls made with VB6 with others made with VC++.
The obvious way is to edit the dialogs with Visual Studio C++ resource editor, and replace each control with its equivalent control. The problem is that I have a lot of dialogs (about 1000).
Is there a easy way to do this?
A possible way could be to generate an application that load the dialogs, and replace the controls during the execution, and then generate and RC file with the resultant dialogs. Something similar to what makes Visual Studio C++ resource editor.
I have tried to implement this solution, but I don't find the way to generate an RC file from a dialog loaded during the application execution.
Any help will be appreciated,
Best regards.
|
|
|
|
|
I assume that the original 32-bit code used VB6-specific control elements, that the source code (text) for the RC file is unavailable, and that you are familiar with the .RC (source code for resources) file format.
To my knowledge, there is no fully automated method of performing the conversion. What you must do is the following:
- Extract the resources from the .EXE file using a resource file editor.
I have used ResEdit (freeware) for examining resources in EXE files. IIRC, it can also extract resources from an EXE/DLL. - Convert any VB6-specific elements to generic Windows versions
Each dialog etc. specifies its "class" type, which affects how it is displayed. This includes the DLL that must be loaded in order to display it. Convert any VB6-specific names to the generic equivalent (e.g. "VB6button" should be renamed "button", "VB6dialog" should be renamed "dialog", etc.) - EDIT: Some ActiveX controls may have no generic control that can replace them. In this case, you must decide whether to use a class library that supplies the missing functionality, or eliminate them from the file.
- Recompile the RC file using the Visual Studio resource editor.
You should get an application that has standard dialog boxes. It will presumably require lots of tweaking before the layout etc. looks OK, but it is a good starting point.
Good luck!
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
As much as I understand:
Non-MFC projects / Projects with ATL support use CString via atlstr.h
MFC projects use CString via cstringt.h
They are source-code compatible, bbut not link time compatible; so if I have a static library that does use CString and that I want to use in both an MFC and a non-MFC project, I have to build the library in two configurations - with / without MFC support.
Is there any sane way to build the library and link it to both MFC and non-MFC projects?
|
|
|
|
|
Remove the CString dependency (i.e. use std::string or something else)... as easy CString is to use, they sure jumbled things up by essentially including it in two places (which is what I assume the link time portion means). Now, I am assuming that's what they mean by "not being link-time compatible" means. You can verify by using a tools to look for the CString symbols in either library (in linux you'd use the "nm" utility, there must be a Windows equivalent but not sure of the name).
|
|
|
|
|
i am getting error
error : expected unqualified-id
public ref class Form1 : public System::Windows::Forms::Form
^
error : expected unqualified-id
[STAThreadAttribute]
^
error : use of undeclared identifier 'STAThreadAttribute'
[STAThreadAttribute]
^
3 errors generated.
i am using clang compiler to build the project
what could be the possible reasons for this? How could I solve this?
thanks
|
|
|
|
|
Check the preceding lines to see if there is an incomplete statement.
|
|
|
|
|
there is only pragma and namespace above the error-ed public keyword-
#pragma once
namespace test4 {
namespace System{};
namespace System{namespace ComponentModel{}};
namespace System{namespace Collections{}};
namespace System{namespace Windows{namespace Forms{}}};
namespace System{namespace Data{}};
namespace System{namespace Drawing{}};
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
error is not shown above the public keyword
I had replaced-
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
with
namespace System{};
namespace System{namespace ComponentModel{}};
namespace System{namespace Collections{}};
namespace System{namespace Windows{namespace Forms{}}};
namespace System{namespace Data{}};
namespace System{namespace Drawing{}};
because i was getting error with the first one.
|
|
|
|
|
Those changes are completely wrong. You have removed the using keywords, and added lots of unnecessary brace characters. I suggest you create a new clean Form project from the Visual Studio templates.
|
|
|
|
|
Hi,
If I use using then I get the following errors-
error : expected namespace name
using namespace System; ^
error : use of undeclared identifier
using namespace System::ComponentModel;
^
error : expected namespace name
using namespace System::ComponentModel;
^
error : use of undeclared identifier
using namespace System::Collections;
^
and so on....including buttons...
So, I used the namespace with curly braces{} suggested somewhere on the net
Using that I don't get these errors but then I have trouble with Public keyword.
what can I do? Is clang compiler doing this?
|
|
|
|
|
VScoder12 wrote: So, I used the namespace with curly braces{} suggested somewhere on the net Don't. Using information from the internet without knowing what you are doing is not the way to get your program to work.
I am beginning to suspect that you are not using the CLR option on your project, so the compiler thinks this is unmanaged C++. Check your settings again.
|
|
|
|
|
I used Visual C++ > CLR > Windows Forms Application in my project creation
I think it is not recognizing the System namespace
If I use curly braces i think it recognizes System namespace but then it does not recognize the Private keyword
any suggestion?
|
|
|
|
|
VScoder12 wrote: any suggestion? Not really. I have just created a new Windows Forms application using Visual C++ 2010 Express, and it creates the correct files, and compiles without error. I can only assume that something is missing from your Visula Studio setup that causes these errors. The generated code of the two main files is as follows, you could try it in your system.:
#pragma once
namespace WinForm {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
~Form1()
{
if (components)
{
delete components;
}
}
private:
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->components = gcnew System::ComponentModel::Container();
this->Size = System::Drawing::Size(300,300);
this->Text = L"Form1";
this->Padding = System::Windows::Forms::Padding(0);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
}
#pragma endregion
};
}
#include "stdafx.h"
#include "Form1.h"
using namespace WinForm;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew Form1());
return 0;
}
|
|
|
|
|
if i use win32 then mine also compile and runs successfully
but i am having trouble with compiling/building with clang compiler as mentioned earlier
|
|
|
|
|
Clang doesn't support C++/CLI, while Microsoft's compilers do. That's the issue.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
VScoder12 wrote: clang compiler What is that, and what does it have to do with Visula Studio?
|
|
|
|
|
Clang Compiler[^]
An open-source compiler.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Yeah, I missed the significance of that in the opening question.
|
|
|
|
|
|
I implemented a multi language UI in a MFC program, since only a few controls, so I write translation in code, I knew it can be implemented with DLL, or String Table.
Now I wonder what way is better, in code, string table, or DLL,according to run time performance and space consuming.
|
|
|
|
|