|
Use SetDialogBkColor() to set the color of the dialog box.
Regards,
Brahmma
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
WM_CTLCOLOR WM_PAINT WM_ERASEBKGND and see COLOR_WINDOW
whitesky
|
|
|
|
|
Krishnatv wrote: How to change the color of a dialog box, I need to change the Color of dialog box to the background color of window. Any help can be appreciated.
See the following code:
BRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor==CTLCOLOR_DLG)
hbr=CreateSolidBrush(RGB(128,45,128));
return hbr;
}
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
I think this is better
COLORREF Color;
Color=GetDC()->GetBkColor();
<code>(1)
void CtetDlg::OnPaint()
{
CPaintDC dc(this);
dc.FillSolidRect(0,0,GetSystemMetrics (SM_CXSCREEN),GetSystemMetrics (SM_CYSCREEN),
Color);
CDialog::OnPaint();
}
-------------------------------
(2)
HBRUSH CtetDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
return (HBRUSH)GetStockObject(WHITE_BRUSH);
}
(3)
BOOL CtetDlg::OnEraseBkgnd(CDC* pDC)
{
return CDialog::OnEraseBkgnd(pDC);
}
</code>
whitesky
|
|
|
|
|
|
Hi,
I have a problem with app icons. I developed an app that can be compiled for different users. Each of this users has it's own app icon and a splash screen. The splash screen is not a problem but the icon is. For now I'm doing the copy/paste of user icons over the old ones before compiling the app. Is there a way to automate this (set an ifdef in the rc file, set some precompile options in VS...)?
I,m using VS.NET 7.0
Thanks
|
|
|
|
|
yea,
use #ifdef to do the same.
On Loading Icon,
#ifdef __CUSTOM1
HICON hIcon LoadIcon(ICON_CUSTOM1);
#else __CUSTOM2
HICON hIcon LoadIcon(ICON_CUSTOM1);
SetIcon(hICon,true);
SaRath.
"It is your attitude, not your aptitude, that determines your altitude - Zig Ziglar."
My Blog | Understanding State Pattern in C++
|
|
|
|
|
I suppose that this works when I must load the icon on app runtime or not ... (if not where I must put this code)? I have to compile the app with the selected icon - the selected icon must be visible in windows explorer (explorer, desktop...)
|
|
|
|
|
Hello Friends,
I am working on Outlook Object Model(Beginner).
I am developing Addin for Outlook 2002.(There is No Version problem.I think So)
If I create a project in VC6.0 Environment then its DLL works properly in Outlook .
But if I develop same type of project In Visual Studio.NET environment it does not give any error but unable to work in Outlook.
What is the problem with .Net Environment?
Please Tell Me.
Thanking You.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
Which VS.NET version are you using? Did you add the correct dll references for the outlook and office libraries?
Mahesh KulkarniWhat is the problem with .Net Environment?
There is no problem. If you are using VS2005 then you need Visual Studio Tools for Office (VSTO) to create add-ins.
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
|
|
|
|
|
Firstly Thanks For The Reply.
I am working on VS.NET 2003.
I am following standard method for creating Addins which is working on VS 6.0 editor. Does I need to add any thing extra in VS.NET. If yes then what and from where?
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
Mahesh KulkarniI am following standard method for creating Addins which is working on VS 6.0 editor
Ok, so what is the standard method? Man, why don't you google? There are a whole bunch of websites which teach you how to create Office add-ins in .NET 2003.
Check out
this[^] and this[^]
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
|
|
|
|
|
Again Thanks...
But as this is Visual C++/MFC forum I asked question on MFC. And unfortunatly u gave me the links related to VB.NET and C#.NET.
But Thanks For your Try.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
Oh. By Visual Studio.NET you mean VC++7.0 and I thought you meant managed code. Well, I create an unmanaged add-in in VC++7.0 the same way I create it in VC++6.0 and it works fine. Have you imported the correct type libraries?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
The question is as the title. I want to know where can I find the instruction
about this aspect. thank you!
|
|
|
|
|
hi !
I am facing a problem loading a DLL file in client application. I am using a LoadLibrary() function to load a dll file. The problem is that ; load library does not return NULL. I cheked this using value of the handle its returning. But getLastError gives error code 6 :: "Invalid Handle".
I checked the path several times. There is no problem in path for sure.
I dont know where i am goin wrong??
Plz help me out.
I am posting my code here
NewDll.cpp (win32 DLL project)
#include "stdafx.h"
HINSTANCE gl_hModule = NULL;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
gl_hModule = (HINSTANCE)hModule;
break;
}
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
return TRUE;
}
}
void getString(HINSTANCE hInst)
{
char load_str[80];
LoadString(hInst,1,load_str,80);
MessageBox(NULL,load_str,"STring Retrieved",NULL);
}
TestDllDlg.cpp( Client app , I am loadin dll in OnOK() function just to test)
[code]
#include "stdafx.h"
#include "TestDll.h"
#include "TestDllDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
typedef void (*MYAPP)(HINSTANCE);
MYAPP gets1=NULL;
HINSTANCE ghInst =NULL;
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
CTestDllDlg::CTestDllDlg(CWnd* pParent )
: CDialog(CTestDllDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CTestDllDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CTestDllDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
END_MESSAGE_MAP()
BOOL CTestDllDlg::OnInitDialog()
{
CDialog::OnInitDialog();
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);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
return TRUE;
}
void CTestDllDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CTestDllDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CTestDllDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CTestDllDlg::OnOK()
{
HMODULE hMod ;
BOOL bRes;
ghInst= LoadLibrary("F:\\MyProjects2\\NewDll\\Debug\\NewDll.dll");
if(ghInst==NULL)
{
MessageBox("CANT LOAD THE LIBRARY","ER0ROR",NULL);
}
gets1 = (MYAPP) GetProcAddress(ghInst,"getString");
HINSTANCE tempInst=GetModuleHandle(NULL);
(*gets1)(tempInst);
bRes = FreeLibrary(hMod);
CDialog::OnOK();
}
|
|
|
|
|
And what is the problem exactly ? If the function returns a valid handle, you can use, you only need to check GetLastError when there is a problem. Can you retrieve successfully the function address ?
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
>>Can you retrieve successfully the function address ?
Thats the problem buddy!
It cant retrive function address! gives me error 126::procedure not found!!
And it must be because of invalid handle!!
|
|
|
|
|
sach!! wrote: Can you retrieve successfully the function address ?
Thats the problem buddy!
It cant retrive function address! gives me error 126::procedure not found!!
The procedure not found is due to C++ compiler mangles the function names...
So you use to define the function using C-style like extern "C" etc.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
sach!! wrote: And it must be because of invalid handle!!
Why ? It can also simply be that you misspelled the function name for example.
Did you compile your dll with a definition file (.def file) ? I think this is required in order to be able to retrieve the function names without knowing their decorated names. Or, pass the decorated name of the function when calling GetProcAddress.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
It seems not problem in your code if you get a handle with LoadLibrary
whitesky
|
|
|
|
|
Why is the "return TRUE; " in the switch statement? It should look like this:
BOOL APIENTRY DllMain(
HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
gl_hModule = reinterpret_cast<HINSTANCE>(hModule);
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
Steve
|
|
|
|
|
You really went through that entire code section. How good..
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
I only had a superficial look but that error jumped out at me.
Steve
|
|
|
|
|
Thx a lot Steve!
That solved my problem . Error code 6 is still there but i am getting procedure address. Now Its giving me error 1814 resource not fount .
what the!!!?
|
|
|
|