|
To eliminate the menu items, simply remove the ID_FILE_OPEN, ID_FILE_NEW and ID_FILE_MRU_FILE1 menu items from the the menu associated with you document template, but leave them in the default menu IDR_MAINFRAME (which is used when no document is active). You will also need to add a pair of ON_UPDATE_COMMAND_UI() handlers to your CDocument derived class to disable the ID_FILE_OPEN and ID_FILE_NEW commands when a document is active (this will prevent them being invoked via toolbar buttons or accelerator keys). When no document is active, you'll get the default behaviour (they will be enabled, since a handler function is defined).
Stephen C. Steel
Kerr Vayne Systems Ltd.
|
|
|
|
|
|
I assume that you are talking about the CListCtrl...If you are using CListView then you can get a pointer to the underlying CListCtrl by calling GetListCtrl.
CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_YOURLISTCONTROL);
POSITION pos = pList->GetFirstSelectedItemPosition();
while (pos)
{
// item is the list index
int nItem = pList->GetNextSelectedItem(pos);
// now you can use GetItem to get information
}
|
|
|
|
|
Thanks. But how is it done without using MFC? I'm talking about the "List Control" you can add to your dialog in the resource editor.
THanks
|
|
|
|
|
|
I'm currently working on a plugin system for an application I'm writing and I'm a bit confused as to why MSVC++6 requires the DLL to have all external symbols resolved.
For instance, lets say a function PluginInit() in my plugin calls a function SetName() that is part of the executable. I am currently required to link the DLL with the .obj file from my main program that defines the function SetName() .
Is there any way to get the linker to not resolve all of the symbols untill runtime? dlopen() on Linux does this with shared libraries. If not, the only way I can think of calling these functions is by using function pointers which would be a total mess. For instance:
----
in main application header file:
void SetName (char* name);<br />
void (*SetNamePtr) (char* name);
somewhere in initialization of the application:
SetNamePtr = SetName;
and then in my DLL:
SetNamePtr ("Plugin Name");
----
Is there a better way?
Thanks for all of your help,
Chris
|
|
|
|
|
I think a better solution for you would be to place the functions which Plugins can call in another shared library (DLL) and link both the applications and plugins with that.
In current case when you are linking the applications obj with the dll, a separate copy of code exists in the dll and in the exe.
|
|
|
|
|
Chris Testa wrote:
Is there a better way?
There's always a better way.
One technique I've had good experience with is as follows. Since the application is the one loading the plugin DLL's, give the DLL's init function a pointer to an object containing only virtual function pointers. A small example:
// app header
class AppInterface
{
virtual void DoSomething();
virtual void DoSomethingElse();
};
// app code. Assumes class AppFoo implements the
// AppInterface interface.
AppInterface* p = AppFoo::Instance();
typedef void (*pfn_init_t)(AppInterface*);
hDll = LoadLibrary(...);
pfn_init_t pfnInit = GetProcAddress(hDll, ...);
(*pfnInit)(p); // Calls the DLL's init function, giving it a pointer to the AppInterface interface to play with.
|
|
|
|
|
I have problem when I'm doing pThread programming in unix(or Linux). It is just a C++ programming. Everything is fine and now I want to add something to deal with the critical section problem. I use <semaphore.h> library and use its functions. (e.g. sem_init(...), sem_post(...)...etc.). I got some sample codes from my friend and online to try this library. However, when i compile in unix using g++ (gcc), i got the following error message:
Undefined first referenced symbol in file
sem_init /var/tmp/cceVsnHy.o
sem_wait /var/tmp/cceVsnHy.o
sem_destroy /var/tmp/cceVsnHy.o
sem_post /var/tmp/cceVsnHy.o
I don't know what has happened.....can anyone help me???
Also, a little Linux question. I compile my C++ file in Linux using g++ and got the output file "a.out". In unix (school), i can just type a.out to display those outputs. However, I cannot do it in my Linux computer and said something liked "no such command...". Can anyone help me too??
Thank you very much!!!!!!!!
|
|
|
|
|
You need to link in the phtread library to use the POSIX semaphore functions. Use the -lpthread option.
In Linux, the current directory isn't on the PATH by default. Use "./a.out" to run your program.
|
|
|
|
|
I did!!! i use "g++ project.cpp -lpthread" to compile my code.
It works in my Linux system now, but still doesn't work in my school unix system.
Thanks anyway......my another Linux problem is fixed now!!!
Thanks!!!!
|
|
|
|
|
Which Unix does your school system use? Solaris, AIX, HP-UX, True64, ... ? Have you tried the man pages for semaphore functions?
|
|
|
|
|
I know ListView can show the image in the subitems. but I can not make it work by using CListCtrl ( I have set LVS_EX_SUBITEMIMAGES ).
anyone know this?
thanks.
|
|
|
|
|
I don't think that is one of the available CListCtrl styles (LVS_EX_SUBITEMIMAGES). You can, however, draw images in subitems...you have to give the control the Owner Draw style and supply your own DrawItem routine and draw directly to the subitem rectangle.
|
|
|
|
|
Hi,
I have timers which are started by non-window classes. I need to access some information, from the class which started the timer. For window classes I get the handle of the window using the HWND parameter. How can I access the class information from a timer procedure for non-window classes?
Thanks
Arthi
|
|
|
|
|
You've raised a very interesting problem! Apparently, there's no suitable callback parameter one can use to store a pointer to the object responsible of handling a TimerProc -driven timer. A workaround, if a little contrived one, is to have a map from timers IDs to objects. The following sketches the approach (warning: I haven't even compiled it, look for typos)
class MyClass
{
private:
typedef std::map<UINT,MyClass *> MapFromIdToMyClass
static MapFromIdToMyClass idToMyClass;
protected:
UINT SetTimer(UINT uElapse)
{
UINT id=::SetTimer(NULL,0,uElapse,staticTimerProc);
if(id){
idToMyClass[id]=this;
}
return id;
}
BOOL KillTimer(UINT id)
{
MapFromIdToMyClass::iterator it=idToMyClass.find(id);
assert(it!=idToMyClass.end());
if(!::KillTimer(NULL,id)) return FALSE;
idToMyClass.erase(it);
return TRUE;
}
static VOID CALLBACK staticTimerProc(HWND,UINT,UINT id,DWORD dwTime)
{
MapFromIdToMyClass::iterator it=idToMyClass.find(id);
assert(it!=idToMyClass.end());
(it->second)->TimerProc(id,dwTime);
}
void TimerProc(UINT id,DWORD dwTime)
{
...
}
...
); The idea is to forward all timers to a static TimerProc which uses the map to redirect the call to the associated MyClass object. If you get this to work and find it fit for your needs, please be aware you'll need some kind of concurrency protection (like a CRITICAL_SECTION ) to prevent racing problems that can occur if the timer triggers before the id has been mapped to the associated object.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I ran into this problem just yesterday and what I have done is sent in my this pointer in the user DWORD and the static member function of my class references that pointer as the pointer to the object to process the data.
I wrapped the processing of the TimerProc that uses the "unsafe" pointer in a try block to catch any exceptions if for some reason the pointer was not an object that I am interested in.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
i will really appreciate if some one can tell me a fixed point rotation function for vc which could rotate an image at angles of
1-10 degrees..(rotation with point)
looking forward from all the gurus of code
|
|
|
|
|
you can use SetWorldTransformation on NT/2K/XP to rotate a DC.
otherwise, you'll have to rotate the image pixel-by-pixel. there is code on this site to do it with shearing and i've seen some on codeguru that will rotate a DIB via a reverse transformation.
of course, if you are looking for a high-quality solution, i know where you can get one...
-c
Cheap oil. It's worth it!
|
|
|
|
|
Why not use the .NET GDI+. Its easy to do with that. And u can do it in any lang... VC included
|
|
|
|
|
Sudip wrote:
Why not use the .NET GDI+.
currently, .Net requires that you ship a 20+MB runtime package. that alone is reason enough for me not to use it.
-c
Cheap oil. It's worth it!
|
|
|
|
|
Actually, GDI+ requires you to install a PSDK, and ship a single dll, which is available from Microsoft also.
Having said that, GDI+ is not a good solution for rotating bitmaps. It doesn't do it in a way that I would regard to be overly useful.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
GDI+ does NOT require .NET, merely an install of the platform SDK.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
i think this is the toughest ...
is there a way i can detect edges of an image .. in simple words i want to inhance,clarify and most importantly want to detect the edges of an image..
looking forward from all the gurus of code
|
|
|
|
|
yes. start with the top left corner pixel. scan across the top row of pixels: if one pixel doesn't "match" the top-left corner, that row is in the image, everything above it is border. do the same thing for the other three edges. "match" can be as strict or as loose as you're willing to allow.
or... see my above post for something that can already do this.
-c
Cheap oil. It's worth it!
|
|
|
|