|
You can statically link all the dependencies to a C++ program and run it from a CD. You can even choose not to link any run time libraries at all and make a "pure" Win32 program.
|
|
|
|
|
I'm attempting to work with PropertyGrids in Visual C++ for the first time, and I'm having difficullty figuring out how to change the Attributes. I want to change the Category as well as the Descriptions, but the only documentation I can find on this is for C#. According to that I'm suppose to use the [Description] and [Category] attributes before the property, but when I use them in C++ I get attributes not found error. I tried creating these as custom attributes but that didn't effect the grid. Is there another way to do this? Are there different attributes to use? Or is there some special Attributes library I've not included?
Thanks!
|
|
|
|
|
So if you are doing .NET development in C++ so C++/CLI you should be in the C++/CLI forum. This form is for C/C++ development.
Your problem could be that you have not referenced the appropriate assembly. The assembly needed is included in the documentation.
led mike
|
|
|
|
|
Hello
I have downloaded this code from the internet and I am trying to compile it. Howerver, I keep getting these 2 errors which I cannot seem to solve.
Error C2491 StartNativeProcessing definition of dllimport function not allowed
Error C2491 StartNativeProcessingWithControlProc definition of dllimport function not allowed.
Many thanks for any assistance with this code.
Steve
#ifdef NATIVEDLL_EXPORTS<br />
#define NATIVEDLL_API extern "C" __declspec(dllexport)<br />
#else<br />
#define NATIVEDLL_API __declspec(dllimport)<br />
#endif<br />
<br />
typedef void (CALLBACK *NATIVEWORKCOMPLETEPROC)();<br />
<br />
typedef BOOL (CALLBACK *NATIVEWORKCONTROLPROC)(LPARAM lParam);<br />
<br />
NATIVEDLL_API void StartNativeProcessing(NATIVEWORKCOMPLETEPROC workCompleteProc);<br />
<br />
NATIVEDLL_API void StartNativeProcessingWithControlProc(<br />
NATIVEWORKCONTROLPROC workControlProc, LPARAM lParam, NATIVEWORKCOMPLETEPROC workCompleteProc);<br />
<br />
#include "stdafx.h"<br />
#include "NativeDLL.h"<br />
#include <windows.h><br />
#include <commctrl.h><br />
<br />
BOOL APIENTRY DllMain( HANDLE hModule, <br />
DWORD ul_reason_for_call, <br />
LPVOID lpReserved<br />
)<br />
{<br />
switch (ul_reason_for_call)<br />
{<br />
case DLL_PROCESS_ATTACH:<br />
case DLL_THREAD_ATTACH:<br />
case DLL_THREAD_DETACH:<br />
case DLL_PROCESS_DETACH:<br />
break;<br />
}<br />
return TRUE;<br />
}<br />
<br />
NATIVEWORKCOMPLETEPROC g_workCompleteProc = NULL;<br />
NATIVEWORKCONTROLPROC g_workControlProc = NULL;<br />
<br />
const int workSleepTimeInMilliseconds = 1500;<br />
<br />
DWORD WINAPI ThreadFunc(void* pvThreadParam);<br />
void DoWork();<br />
<br />
NATIVEDLL_API void StartNativeProcessing(NATIVEWORKCOMPLETEPROC workCompleteProc)<br />
{<br />
g_workCompleteProc = workCompleteProc;<br />
g_workControlProc = NULL;<br />
<br />
DWORD dwThreadId;<br />
CreateThread(0, 0, ThreadFunc, NULL, 0, &dwThreadId); <br />
}<br />
<br />
NATIVEDLL_API void StartNativeProcessingWithControlProc(<br />
NATIVEWORKCONTROLPROC workControlProc, LPARAM lParam, NATIVEWORKCOMPLETEPROC workCompleteProc)<br />
{<br />
g_workCompleteProc = workCompleteProc;<br />
g_workControlProc = workControlProc;<br />
<br />
DWORD dwThreadId;<br />
CreateThread(0, 0, ThreadFunc, (void*)lParam, 0, &dwThreadId); <br />
}<br />
<br />
DWORD WINAPI ThreadFunc(void* pvThreadParam)<br />
{<br />
int loopControl = 0;<br />
<br />
do<br />
{<br />
DoWork();<br />
if (g_workControlProc != NULL)<br />
loopControl = g_workControlProc((LPARAM)pvThreadParam);<br />
}<br />
while(loopControl != 0);<br />
<br />
if (g_workCompleteProc != NULL)<br />
g_workCompleteProc();<br />
<br />
return 0;<br />
}<br />
<br />
void DoWork()<br />
{<br />
Sleep(workSleepTimeInMilliseconds);<br />
}
|
|
|
|
|
steve_rm wrote: #ifdef NATIVEDLL_EXPORTS
#define NATIVEDLL_API extern "C" __declspec(dllexport)
#else
#define NATIVEDLL_API __declspec(dllimport)
#endif
Why is export extern "C" but import not the same?
Regardless, the NATIVEDLL_API macro should be used only on the function declarations (prototypes),
not on the function definitions/implementations.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
have you #defined NATIVEDLL_EXPORTS anywhere?
|
|
|
|
|
Hello,
I got it working. However, I am not totally sure why.
Why did it work when I removed the NATIVEDLL_API from the function definitions, and what are the macros for?
Can you explain the code below?
Many thanks for you help,
Steve
<br />
#ifdef NATIVEDLL_EXPORTS<br />
#define NATIVEDLL_API extern "C" __declspec(dllexport)<br />
#else<br />
#define NATIVEDLL_API __declspec(dllimport)<br />
#endif
|
|
|
|
|
those let you create exports and imports from the same code base. when compiling the DLL, you use the export part, but when using the DLL, you use the import part.
it's standard DLL stuff that MS automatically creates for a DLL project.
|
|
|
|
|
I'm developing a game in win32 c++ DirectX.
On my graphic game window I have a picture of a 'close' button. When I click on it I want it to to the same as clicking the 'X' button.
But although I tried several things:
<br />
::SendMessage(hWnd, WM_CLOSE, NULL, NULL);
::SendMessage(hWnd, WM_DESTROY, NULL, NULL);
<br />
DestroyWindow(hWnd);
I get strange bugs that won't happen when I click 'X'.
|
|
|
|
|
PostMessage(WM_SYSCOMMAND,SC_CLOSE,0);
Best Wishes,
-David Delaune
|
|
|
|
|
Thank you very much.
It seems like all crazy bugs are gone.
|
|
|
|
|
Hanan888 wrote: ::SendMessage(hWnd, WM_DESTROY, NULL, NULL);
Don't do that! That doesn't destroy a window
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks.
I Really shouldn't post
::SendMessage(hWnd, WM_DESTROY, NULL, NULL);
as a real candidate.
I was pretty desperate when I posted that message...
|
|
|
|
|
hehe the last act of a desperate programmer
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
"He got sick of it. Sick of life, sick of people, sick of Win32. Desperate and dispirited, he code ::SendMessage(hWnd, WM_DESTROY, NULL, NULL); . And I can tell you this: whatever it does, it doesn't destroy a window..."
|
|
|
|
|
Excellent!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Don't do that! That doesn't destroy a window
Opps, let me check how many windows has been destroyed by me till date!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Huh? What are you talking about Alok?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello
I am looking for a graphing library simalar in look/functionality to MSAGL (previously called GLEE, see:
http://research.microsoft.com/research/msagl/[^]) for a project being developed in c++.
The problem with using MSAGL/GLEE is that it is written in c# for .net and I require a native c++ library which i can link into an existing project under development (build enviroment is borland turbo c++).
Can anybody recomend anything?
Many thanks in advance
J
|
|
|
|
|
on top of my head, maybe GraphViz can do that ?
|
|
|
|
|
Hello All,
Is there any way to restricting a class to be inherited? I dont want any one to inherit my class. I feel this can be possible only by making the constructor in private. Is there any other way to do this?
Regards
Kihore
|
|
|
|
|
I think there is no way (other to switch to .NET programming).
But do you really need such a feature?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Kishore JP wrote: Is there any other way to do this?
A private constructor is the only way that I know of.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Yep.
Only restricting access to the members using the private keyword will cause an impediment to use it as base classe because the private members of the base class are unavailable in the derivates.
There's not a sealed attribute in C++.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|