|
gopalraja wrote: ctrl.AddBitmap(3,IDB_BITMAP3);
This function is used to add bitmap to imagelist associated with toolbar control.
Look at function SetImageList, and use it according to your need.
Images on toolbar shown according to imagelist associated with that toolbar control.
|
|
|
|
|
Hi,
You can set cold and hot images for the toolbar.
This is the sample code.
CImageList img;
img.Create(IDB_HOTTOOLBARS, 22, 0, RGB(128, 128, 128));
m_wndToolBars.GetToolBarCtrl().SetHotImageList(&img);
img.Detach();
img.Create(IDB_COLDTOOLBAR, 22, 0, RGB(255, 255, 255));
m_wndToolBars.GetToolBarCtrl().SetImageList(&img);
img.Detach();
Here m_wndToolBars is the CToolBar object.And IDB_HOTTOOLBARS and IDB_COLDTOOLBAR are the Bitmap imges in the resourse editor.
Regards
Arun
|
|
|
|
|
I want the source code for getting list of software installed in a system.
|
|
|
|
|
You had posted same question previously for which you got answers.. What is problem with those answers
Why reposting again?
Regards,
Sandip.
|
|
|
|
|
|
I am working on a 64 bit system (windows XP).I have a problem in launching an MFC dialog, that contains an active-x control (MSFlex Grid control).My project builds successfully without any errors.But when i try to launch this dialog, i get an error "Debug Assertion Failed".My Msflxgrd.ocx file is registered successfully.I don't understand where the problem is.Do let me know where the problem is.Please help me out ......
Thnx in advance.
|
|
|
|
|
This problem can arise if the dialog application is build for x64 and the flex grid is a 32 bit activeX.
«_Superman_»
|
|
|
|
|
Firstly, thnx for the reply.
I have a question, though...if i am working on a 64bit machine, then the active x control (Msflxgrd.ocx) will be for 64bit right?How is it possible that i can built a dialog for 64bit with 32 bit active x control?Is there anything else that is required to be done on my project settings or any other file that i am suppose to use or download.Please do lemme know. Thnk You.
|
|
|
|
|
It is not necessary that the flex grid is also 64 bit.
Even though the OS is 64 bit, you can create 32 bit binaries.
Basically a 64 bit binary cannot load any 32 bit modules (.dll, .ocx etc.)
Similarily 32 bit binaries cannot load 64 bit modules.
So make sure the dialog app and flexgrid have the same bitness.
«_Superman_»
|
|
|
|
|
I have checked my dialog app and flexgrid.Both are 64bit.
I don't just understand what the problem is.Please do let me know.
|
|
|
|
|
If you can give me the stack trace and the code in you InitDialog function I could try and find out.
«_Superman_»
|
|
|
|
|
Hi....
My code is pasted here below.I developed this in VS 2005, type of project: MFC Application(.exe)
When i debug the code, it fails in function CreateDlgIndirect (in dlgcore.cpp which is system file)
Please do have a look.Thnx again.
BOOL CMFCExecutableApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_MFCExecutableTYPE,
RUNTIME_CLASS(CMFCExecutableDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CMFCExecutableView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// Connect the COleTemplateServer to the document template
// The COleTemplateServer creates new documents on behalf
// of requesting OLE containers by using information
// specified in the document template
m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
// Register all OLE server factories as running. This enables the
// OLE libraries to create objects from other applications
COleTemplateServer::RegisterAll();
// Note: MDI applications register all server objects without regard
// to the /Embedding or /Automation on the command line
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
return FALSE;
}
m_pMainWnd = pMainFrame;
// call DragAcceptFiles only if there's a suffix
// In an MDI app, this should occur immediately after setting m_pMainWnd
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// App was launched with /Embedding or /Automation switch.
// Run app as automation server.
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
{
// Don't show the main window
return TRUE;
}
// App was launched with /Unregserver or /Unregister switch. Unregister
// typelibrary. Other unregistration occurs in ProcessShellCommand().
else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
{
m_server.UpdateRegistry(OAT_DISPATCH_OBJECT, NULL, NULL, FALSE);
AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor);
}
// App was launched standalone or with other switches (e.g. /Register
// or /Regserver). Update registry entries, including typelibrary.
else
{
m_server.UpdateRegistry(OAT_DISPATCH_OBJECT);
COleObjectFactory::UpdateRegistryAll();
AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid);
}
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
|
|
|
|
|
I would like to see the code where the actual crash happens.
I'm guessing this is the code where the dialog or form view is being initialized.
«_Superman_»
|
|
|
|
|
Hi.....
Thnx for the reply.I have pasted the code below from dlgcore.cpp.The code fails at function CreateDlgIndirect.Do have a look.
If possible plse create an MFC Application in VS 2005 and insert an active x control (MS FLEX GRD) and execute it.i think you might get the error "Debug Assertion failed", while executing the dialog.to remind, my system is a 64bit system .Thnx once again.Please do let me know if you get to know the problem.
thnx.
INT_PTR CDialog::DoModal()
{
// can be constructed with a resource template or InitModalIndirect
ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
m_lpDialogTemplate != NULL);
// load resource as necessary
LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
HGLOBAL hDialogTemplate = m_hDialogTemplate;
HINSTANCE hInst = AfxGetResourceHandle();
if (m_lpszTemplateName != NULL)
{
hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);
hDialogTemplate = LoadResource(hInst, hResource);
}
if (hDialogTemplate != NULL)
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
// return -1 in case of failure to load the dialog template resource
if (lpDialogTemplate == NULL)
return -1;
// disable parent (before creating dialog)
HWND hWndParent = PreModal();
AfxUnhookWindowCreate();
BOOL bEnableParent = FALSE;
#ifndef _AFX_NO_OLE_SUPPORT
CWnd* pMainWnd = NULL;
BOOL bEnableMainWnd = FALSE;
#endif
if (hWndParent && hWndParent != ::GetDesktopWindow() && ::IsWindowEnabled(hWndParent))
{
::EnableWindow(hWndParent, FALSE);
bEnableParent = TRUE;
#ifndef _AFX_NO_OLE_SUPPORT
pMainWnd = AfxGetMainWnd();
if (pMainWnd && pMainWnd->IsFrameWnd() && pMainWnd->IsWindowEnabled())
{
//
// We are hosted by non-MFC container
//
pMainWnd->EnableWindow(FALSE);
bEnableMainWnd = TRUE;
}
#endif
}
TRY
{
// create modeless dialog
AfxHookWindowCreate(this);
if (CreateDlgIndirect(lpDialogTemplate,
CWnd::FromHandle(hWndParent), hInst))
{
if (m_nFlags & WF_CONTINUEMODAL)
{
// enter modal loop
DWORD dwFlags = MLF_SHOWONIDLE;
if (GetStyle() & DS_NOIDLEMSG)
dwFlags |= MLF_NOIDLEMSG;
VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
}
// hide the window before enabling the parent, etc.
if (m_hWnd != NULL)
SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
}
}
CATCH_ALL(e)
{
DELETE_EXCEPTION(e);
m_nModalResult = -1;
}
END_CATCH_ALL
#ifndef _AFX_NO_OLE_SUPPORT
if (bEnableMainWnd)
pMainWnd->EnableWindow(TRUE);
#endif
if (bEnableParent)
::EnableWindow(hWndParent, TRUE);
if (hWndParent != NULL && ::GetActiveWindow() == m_hWnd)
::SetActiveWindow(hWndParent);
// destroy modal window
DestroyWindow();
PostModal();
// unlock/free resources as necessary
if (m_lpszTemplateName != NULL || m_hDialogTemplate != NULL)
UnlockResource(hDialogTemplate);
if (m_lpszTemplateName != NULL)
FreeResource(hDialogTemplate);
return m_nModalResult;
}
|
|
|
|
|
Hello,
I have two programs that run well independently. One controls motion, the other is for viewing with a webcam. Each is intended for a human operator.
I have c++ source code for the camera program.
I do not have source code for the motion controller but I do have c++ source code for a dll plugin for the motion controller. The plugin has the necessary functions.
I would like to add a feature to the camera program so that it calls a function in the motion controller plugin and gets the returned value.
How can I define a function in the motion controller plugin so that it is callable from the camera program?
What is this scenario called and what keywords will help me search for information or examples?
Tom Hubin
thubin@earthlink.net
|
|
|
|
|
Presuming you're using Visual C++...
You want to use __declspec(dllexport) to define functions that are exported from the DLL and are thus callable from any other program (including the camera program). The best way to use it is like this:
- Declare the DLL's exported functions in a header file (note - replace THIS_FILE_H with some text representing the headers actual filename - THIS_FILE_H represents 'ThisFile.h'):
#ifndef __THIS_FILE_H__
#define __THIS_FILE_H__
#ifndef PLUGIN_API
#define PLUGIN_API __declspec(dllimport)
#endif
PLUGIN_API int DoSomething(int aParameter);
#endif // __THIS_FILE_H__
- Add a .cpp file to the plugin DLL project which defines the functions (
DoSomething in this case) you've exported. You need the following two lines in that file, BEFORE you define any of the functions (note: replace 'ThisFile.h' with whatever you called the header file in the previous step):
#define PLUGIN_API __declspec(dllexport)
#include "ThisFile.h" - In the camera program,
#include the header in the .cpp file where you want to call the plugin's functions. You also need to link the plugin's export library (a .lib file) to the camera program.
This page[^] has several useful links.
|
|
|
|
|
Hello Stuart,
I posted a reply about half an hour ago and it has not shown up on the forum. So I am experimenting to see if I used the wrong procedure to reply.
Tom Hubin
thubin@earthlink.net
|
|
|
|
|
Hello Stuart,
Well, I guess my first reply to you is lost in cyberspace. I'll try again.
BTW, I am using c++ in Visual Studio 2003.
The procedure that you suggest makes sense to me. I also used some of the keywords to find help topics. These also agreed. However, as you well know, the devil is in the details.
I am getting two warnings and cannot figure out why. Below are my brief header and cpp files and the warnings. What am I missing? Ignore the third warning.
I would not normally worry about a couple of warnings but I am also having errors compiling the calling program. So I am wondering what I need to specify to create the library here and how to import it at the calling end.
Tom Hubin
thubin@earthlink.net
**************************************************
// public.h
#ifndef __PUBLIC_H__
#define __PUBLIC_H__
//#pragma once
#ifndef PLUGIN_API
#define PLUGIN_API __declspec(dllimport)
#endif
PLUGIN_API int DoubleIt(int aaa);
#endif // __PUBLIC_H__
**************************************************
// public.cpp
#include "stdafx.h"
#include "dbg.h"
#define PLUGIN_API __declspec(dllexport);
#include "public.h"
PLUGIN_API int DoubleIt (int aaa)
{
int bbb ;
bbb = 2*aaa ;
return(bbb);
}
**************************************************
Output Window Compiling...
stdafx.cpp
Compiling...
XMLProfile.cpp
Utility.cpp
public.cpp
c:\CNC\Mach3Development\SDK2.62.00\th3dVid\public.h(12) : warning C4091: '__declspec(dllexport ) ' : ignored on left of 'int' when no variable is declared
c:\CNC\Mach3Development\SDK2.62.00\th3dVid\public.cpp(14) : warning C4091: '__declspec(dllexport ) ' : ignored on left of 'int' when no variable is declared
PluginTestDlg.cpp
dbg.cpp
CustomPluginImpl.cpp
c:\CNC\Mach3Development\SDK2.62.00\MachIncludes\Mach4View.h(18) : warning C4192: automatically excluding 'IServiceProvider' while importing type library 'ShockwaveFlash.ShockwaveFlash'
CustomPlugin.cpp
Generating Code...
Compiling resources...
Linking...
Creating library Debug/CustomPlugin.lib and object Debug/CustomPlugin.exp
Performing Post-Build Event...
1 file(s) copied.
Results Build log was saved at "file://c:\Cnc\Mach3Development\Sdk2.62.00\th3dVid\Debug\BuildLog.htm"
CustomPlugin - 0 error(s), 3 warning(s)
**************************************************
|
|
|
|
|
You've got a semi-colon at the end of #define PLUGIN_API __declspec(dllexport)<span style="font-weight: bold;">;</span> - you don't want that.
Also - you don't need to use PLUGIN_API in the cpp file - doesn't hurt, but it's not required.
|
|
|
|
|
Hello Stuart,
Thanx for catching that semicolon.
All compile and run ok.
In DoubleIt() I have added a call to the motion control EXE program for which the plugin is written and by which the plugin has been loaded. This new DoubleIt() works ok when called from elsewhere within the plugin but not when it is called from the vision control EXE program.
When the plugin function is called from the vision control EXE I get the message "The instruction at "0x0000000" referenced memory at "0x00000000". The memory could not be read."
This only occurs if the called plugin function is trying to call a function in its parent EXE. BTW, I get that same error message if the DLL is not loaded at all.
I think that the called plugin function is not exactly the same as the one that is loaded with the DLL. I am guessing that all the pointers must be found in memory as needed.
How do I setup the compiler options so that the vision control EXE program can call the motion control EXE program via the motion control's DLL plugin. Or perhaps directly from the vision control EXE to the motion control EXE since the motion control EXE program must have used dllexport so that the plugin can call motion control functions.
Tom Hubin
thubin@earthlink.net
|
|
|
|
|
Tom Hubin wrote: How do I setup the compiler options so that the vision control EXE program can call the motion control EXE program via the motion control's DLL plugin
Nothing to do with compiler options, I suspect. I guess the plugin is expecting the executable that loads it to provide certain capabilities - there must be some defined mechanism by which it knows the addresses of the functions in the EXE.
Tom Hubin wrote: motion control EXE program must have used dllexport so that the plugin can call motion control functions
Not necessarily - there might be some other mechanism by which the plugin can get function addresses.
I feel you're on your own, I'm afraid - if there's a specification for the plugin interface, that might define how you get the exe function addresses?
|
|
|
|
|
Create a named event in the plugin and wait on that event to become set.
When the event becomes set, call the required function.
From the camera program set the event when needed.
You may want to look at CreateEvent and SetEvent .
«_Superman_»
|
|
|
|
|
Hi all,
i have an CListCtrl, i m sort it according to diffrent columns in acsending or decsending order.
i want to set up and down arrow on list header according to sorting.
please explain me with example.
how can i do this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
modified on Thursday, January 29, 2009 1:55 AM
|
|
|
|
|
You can modify the header text .. Does it make sense??
Regards,
Sandip.
|
|
|
|
|
The way it's done in the sorted list view control in the WTL library[^] is to use the hbm member of the HDITEM [^] attribute of the header of the sorted column to set an up arrow or down arrow bitmap for the header. If you tell the bitmap to be to the right of the header's text, you'll get the effect you're wanting.
The bitmaps are available in shell32.dll as image resources 133 and 134.
You can learn a lot about this by looking at the implementation of CSortListViewImpl in the file atlctrlx.h in WTL...
The SetSortColumn method of this class shows how to set the bitmaps correctly, while the CreateSortBitmaps method shows how to create the bitmaps.
|
|
|
|