|
I am calling a modal dialog from a dll. I have a button on my main application that when pressed calls a dialog from the dll. Note I am not saying this approach is correct but it is what I have.
void CHTPCCOREDlg::OnButton1()
{
PLUGIN.m_pPlugin->Initialize();
}
void CPlugin::Initialize()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CPlugin dlg;
dlg.DoModal();
}
Which seems to work fine. Then in the dll when I want to return to the main application I have the following code.
void CPlugin::CheckKeyState() // called from a timer
{
if(IsKeyDown(VK_BACK))
{
Cleanup();
CDialog::OnOK();
}
}
All is fine and dandy the first go around. I start the app. I press the button to call the dll. The dll shows it's dialog as expected. I hit the Backspace key and the plugins dialog closes and all is fine. Well, until the press the button to initialize the plugin for a second time. The app just hangs. It appears that the dialog is attempting to display but it never does. I can then press the backspace key again then a press of the button to init the plugin works again.
Any pointers would be appreciated.
|
|
|
|
|
Check AfxSetResourceHandle() function: It may help...
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
Thanks for the suggestion. I will look at the function you mentioned.
In the mean time I found the problem. I have a function to go full screen.
fs = !fs;
GoFullScreen(this->m_hWnd, fs, &sizerect);
In early stages I had fs defined globally to 0. So the first time thru the function went fullscreen. The second time thru it was being set to not use full screen which I have not tested and which obviously does not work yet.
Thanks for your response.
|
|
|
|
|
Hi everyone!
I need to create a button array that can be resized.
I tought it was easy like in VB but I got a problem. I'm unable to create buttons!
For example, I placed this is my header file :
CButton* myButton;<br />
<br />
int nbButtons;<br />
<br />
void InsertButton(LPCTSTR lpszText);
Then in the implementation file, I've set
void CLinkList::InsertButton(LPCTSTR lpszText)<br />
{<br />
if(nbButtons<1)
myButton=(CButton*)malloc(sizeof(CButton)*(nbButtons+1)); <br />
else
myButton=(CButton*)realloc(myButton, sizeof(CButton)* (nbButtons+1)); <br />
<br />
CRect rect(0,nbButtons*25,60,20);<br />
<br />
myButton[nIndex].Create( lpszText, WS_VISIBLE | WS_CHILD, rect, this, GetDlgCtrlID() );<br />
<br />
nbButtons++;<br />
<br />
}
But I'm not able to create any button. I didn't get any assertion error but it stop within the CButton::Create function. I don't have any idea of what is the problem.
I know that if I create a static array like :
CButton myButton[30];
it works very well...
What's wrong with the way I do, and how can I solve it? Notice that I want my array to be resized because I don't want to hold a "big" static array. And probably because I'm curious to know how it works too!
It will be very appreciated if somebody here could help me!!
Stef
Progamming looks like taking drugs...
I think I did an overdose.
|
|
|
|
|
I just had this problem yesterday (sorta).
Instead I used MFC CArray and the problem I was having was that CButton doesn't have a default copy constructor and I wasn't interested in writting one, so I did what was most obvious
Use CArray like this:
CArray<CButton*, CButton*> m_pButtons;
I'm drinking triples, seeing double and acting single
|
|
|
|
|
Most likely the problem lies in your use of realloc . Simply put, realloc won't work except if the types contained in the array are primitive (integer types, pointers, little more.) The reason is that realloc , when moving to a larger block of memory, copies the original contents as if with memcpy , and this is not guaranteed to work for types which provide their own copy constructors.
My suggestion is that you store pointers to CButton instead of CButton objects. This implies an extra allocation per button:
myButton[nIndex]=new CButton;
myButton[nIndex]->Create(...); and don't forget to delete these objects when done.
Also, do yourself a favor and forget about realloc . C++ provides for instance std::vector which does the work in a far easier way.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
It doesn't work...
It stop at:
myButton[nIndex]=new CButton;
I have declared myButton like this :
CButton** myButton;
Any Idea. I have an headhache so, my brain doesn't work as much as I want !
Progamming looks like taking drugs...
I think I did an overdose.
|
|
|
|
|
I get it!!
I just forgot size the array of CButton pointers...
myButton = new CButton*;<br />
myButton[nIndex] = new CButton;
Now, I just have to find out how to resize it !
Tanks a lot
Stef
Progamming looks like taking drugs...
I think I did an overdose.
|
|
|
|
|
I have a COM class in which I have an ATL collection variable, like this:
CAtlList<StructData> MyList;
Where StructData is a user-defined structure.
Now I want to pass the MyList variable to the constructor of a CDialog class, so that the dialog class can read and write data to the variable.
How should this be done?
I get nothing but error messages while trying, so I need help.
|
|
|
|
|
What is the difference between Win32, Windows API, MFC, ATL, and COM?
Forgive my ignorance I am new to Windows programming.
|
|
|
|
|
SDK API = (Software development kit) Application programming interface (Analogous to CRT in DOS kinda). SDK includes the tools and docs required and API is the standard or the function interfaces.
MFC = Microsoft foundation classes is a framework (Basically a bunch of classes which do what the win32 API does, but more OOP friendly)
WTL/ATL=Windows/Active template library. Basically does what MFC does for windows API, but using template classes instead of C++ classes.
COM/ActiveX = Was an idea M$ had which would allow for code to be modularized (if thats a word ) basically kept in a binary form which any supported language could use (VB, C++, Delphi, etc). In C++ programmers have long since passed around code in source form as C++ classes, however programmers were still still free to mess up code, modify it, etc...not ideal for commercial code your trying to sell. COM objects were designed to fix this, by keeping everything binary...so programmers had to manipulate data members via accessor/mutators like any OO purist would tell you to do. Also you hide the implementation much better than a C++ class...because functions which are meant to be private are not visible to client programmers...only interface functions are(actually it's at programmers discretion).
COM=Component object model...basically it's a standard binary communication mechanism required for code (written in delphi, c/c++, etc) to communicate with ActiveX/COM objects. This gets hard to explain briefly...i'd advise you to read an article or two on the idea/theory behind it...MSDN used to have lots...but i'm not sure if ActiveX/COM is as big of a buzz word as it was a few years ago, since the release of .NET...you'd have to ask someone more familiar with what .NET actually is and does
This is as far as I understand it anyways
I'm drinking triples, seeing double and acting single
|
|
|
|
|
Mine was funnier, even if later. :P
-Blake
|
|
|
|
|
Windows API: The application programming interface (API) exposed by the windows operating system. In Unix terms this would be like the OS system call interface, excepting of course of the fact that the Windows API does everything, rather than having half a dozen different APIs you must code to, like Unix, X, Qt, etc.
Win32: Coined to distinguish between the Windows API exposed by old 16 bit versions of Windows, i.e. Windows 1.0-3.11, and 32 bit versions, i.e. Windows 95-ME and Windows NT 3.1-Windows 2003 Server. Win32 is now a synonym for Windows API since the Win16 API is dead and forgotten.
MFC: Microsoft Foundation Classes - the original application framework that Microsoft first shipped with their C 6.0 compiler. It is old and crufty and designed for C++ without templates or other modern features. It tries hard to force everything into the Model-View-Controller design pattern.
ATL: Active Template Library - named in an era when Microsoft was sticking Active on the front of everything, like ActiveX, ActiveServer, ActiveMovie, ActiveBob. This is a newer library, designed primarily to support writing COM components in C++. It uses the language in a much more modern way than MFC, but doesn't cover nearly the same breadth of functionality. You can bold ATL and MFC together in the same application but it isn't really a great match.
WTL: You missed this one, but it is important. This is a library build on top of ATL that broadens it's scope to make it closer to an application framework. It is much lighter and faster than MFC. It has an amusing history of being supported and then unsupported and then supported by Microsoft.
COM: Component Object Model - This was born as OLE2, but left it's parent in the dust and is the standard binary component specification that virtually all Windows software was based around until .NET arrived on the scene. COM is dead, long live COM.
-Blake
|
|
|
|
|
Thanks
|
|
|
|
|
I am just seeking opinions. It has been more that 15 years since I dealt with these types of issues.
I am looking for a database management tool along the lines of how I vaguely remember LANSA and SIGNON for the AS/400.
Requirements:
1. Supports SEQUEL server, other relational databases nice but not required.
2. Builds Tables and Indexes from models.
3. Provides a front end for defining database triggers.
4. Will generate simple maintenance programs. Add/Delete/Inquire on a per table bases or SQL view.
5. Will provide for an upload process. Let me explain this one. Let’s just say I have a master database, and (standalone) clients periodically (weekly) physically attach to my network. Hopefully the tool would assist in importing changed information from these clients and exporting data to these clients.
Again, I am not asking for your deep analysis, but rather for product suggestions or personal views you may have.
Thank you
|
|
|
|
|
I don't know nothing about C++. I built and addin using VB.NET and got from www.microsoft.com a shim object.
This object has a reference to stdafx.h and stdafx.cpp.
Now I can't compile it, I have an error message that says:
c:\Development\CrossNET\COMAddInShim\stdafx.h(48): error C3506: there is no typelib registered for LIBID '{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}'
I tried searching the registry to see what this GUID is about, but can't find nothing.
Can someone please help me with this ??
I need to do a deployment tomorrow morning and QA people are waiting for this component to be compiled.
Thanks
Free your mind...
|
|
|
|
|
Perhaps you should register the type library ? DO you *have* the type library ? Know what a type library is ?
I'd suggest that 'there is no typelib registered' would be a good sign that you're not gonna find this GUID in the registry. That's the problem.
Why link to www.microsoft.com but not the object ? Where did you get it ? What is it going to do for you ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
How do I make them disappear...?
I've tried:
cs.dwStyles = ~ WS_VSCROLL;
But it causes the framework to not create a document or something like that...
Any ideas how I can go abouts doing this...?
I'm sure it's a CMDIChildWnd thats causing the scrollbars to appear because when I add scrollbars to embedded view I get double scrollbars...I also have concluded it's CSplitterWnd thats making scrollbars appear...
Thanks again
I'm drinking triples, seeing double and acting single
|
|
|
|
|
nm...Figure it out...
Cheers
I'm drinking triples, seeing double and acting single
|
|
|
|
|
Haven't you tried
cs.dwStyles ~= WS_VSCROLL;
instead of
cs.dwStyles = ~ WS_VSCROLL;
Bunburry
|
|
|
|
|
This might seem like a trival question, but does a dll or static lib generate faster code? My guess would be static lib, but I really do not know much about dll's. The reason that I ask is that I am writing a bunch of realtime code and I need to make things as fast as possible.
Also, how does one choose when to use a dll or a lib?
Thanks
|
|
|
|
|
|
I think that would be compiler and programmer dependant.
You as the programmer have most control over code speed...
However lib's are probably quicker because everything is linked at compile time and theres no additional over head for linking to an external library at runtime.
Other than that:
int b=0;
for(int i=0; i<10; i++)
b=(b*i)+1;
I would think would compile into the same instructions regardless of output file being DLL or LIB
mwhannan wrote:
Also, how does one choose when to use a dll or a lib?
LIB's are usually passed around when you as the programmer wants differ modules of functionality, but in the finalized product you want one single exe...DLL's are used for keeping final product in seperate modules...making it easy to upgrade parts of your app but only updating a single file...
One is runtime and the other is compile time linkage.
Cheers
I'm drinking triples, seeing double and acting single
|
|
|
|
|
"However lib's are probably quicker because everything is linked at compile time and theres no additional over head for linking to an external library at runtime."
That was what I was thinking. Does "at run time" mean that it is linked when the program first starts up, or it can happen any time during program execution?
"LIB's are usually passed around when you as the programmer wants differ modules of functionality, but in the finalized product you want one single exe...DLL's are used for keeping final product in seperate modules...making it easy to upgrade parts of your app but only updating a single file..."
Thanks, that help clear some things up.
|
|
|
|
|
mwhannan wrote:
Does "at run time" mean that it is linked when the program first starts up, or it can happen any time during program execution?
Can be either...basically at programmers preference instead of complier
Cheers
I'm drinking triples, seeing double and acting single
|
|
|
|