|
go to search and then select files&folders then type which type u want .(.jpg,.bmp)
|
|
|
|
|
Hi all,
VC++(MFC) 6.0
I have to open my application only one time,for that I am using folllowing code
HANDLE hMutex;
hMutex = CreateMutex(NULL,TRUE,TEXT("vision client"));
if(hMutex == INVALID_HANDLE_VALUE)
{
AfxMessageBox("Unable to create Mutex");
}
else
{
if(GetLastError()==ERROR_ALREADY_EXISTS)
{
HANDLE proc_h = GetCurrentProcess();
AfxMessageBox("Application is already Opened !!!");
_exit(0);
}
}
But Instead of closing the application I have to activate the application .
Please help me.
Ranjith
|
|
|
|
|
You could try registering a custom window message on the system using RegisterWindowMessage[^], when you want to activate your app, broadcast this message using BroadcastSystemMessage[^], in your application make a handler for this message and use SetForegroundWindow[^] or some such to activate your application.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Thanks,
I am new to VC++ ,can anybody give me an example please;
ranjith
|
|
|
|
|
I dont really understand your question but try the following and tell me if it is what you really want??
HANDLE hMutex;
hMutex = CreateMutex(NULL,TRUE,TEXT("vision client"));
if(hMutex == INVALID_HANDLE_VALUE)
{
AfxMessageBox("Unable to create Mutex");
}
else
{
if(GetLastError()==ERROR_ALREADY_EXISTS)
{
HANDLE proc_h = GetCurrentProcess();
CWnd* pMainWnd = AfxGetMainWnd();
pMainWnd->SetActiveWindow();
pMainWnd->BringWindowToTop();
AfxMessageBox("Application is already Opened !!!");
_exit(0);
}
}
I have only inserted the lines in bold.
|
|
|
|
|
Thanks,
It's returning NULL in pMainWnd ...
If this is the case I have get the main window handle...
HANDLE hMutex;
hMutex = CreateMutex(NULL,TRUE,TEXT("vision client"));
if(hMutex == INVALID_HANDLE_VALUE)
{
AfxMessageBox("Unable to create Mutex");
}
else
{
if(GetLastError()==ERROR_ALREADY_EXISTS)
{
AfxMessageBox("Application is already Opened !!!");
_exit(0);
}
}
The above code will ristrict the application to open mutliple instances.And it gives the message like "Application is already Opened !!!" . and closes the second instance[_exit(0)].
Instead of giving message I have to activate (maximize)the application if user clicks again on the application icon.
|
|
|
|
|
If you have the handle to window you want to activate, use SW_MAXIMIZE or SW_RESTORE flag of SetWindowPos?
|
|
|
|
|
I donot have the mainwindow handle....
|
|
|
|
|
haha.. so that is the problem.
how about using FindWindow() function? Inside the MainFrame::OnCreate, give a name to your window using SetWindowText and then you can use FindWindow to find the window that matches the name you gave earlier. that is one of the ways.
SetWindowText("My magic window");
If mutex already exists,
HWND hWnd = FindWindow(NULL, "My magic window")
if(hWnd && ::IsIconic(hWnd))
//maximize or restore it
//bring it to top or set it as foreground window
modified on Saturday, September 19, 2009 7:17 AM
|
|
|
|
|
Imho FindWindow isn't really reliable, not to mention that fiddling with windows created by other processes isn't healthy...what's wrong with the message broadcast aproach?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Can any one give me findwindow() example..
|
|
|
|
|
How about searching on CP for single instance application articles? Then you'd have found this one[^], for example.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hai all ,
I have created an application in VC++ using VS2008 in a development machine which runs on Vista, now i need to run that application in a target machine which runs on windows XP SP2 which does not have vc++ dlls or any thing.
i need a help for redistributing the dependent dlls for the application so that it should run well in target machine.
this is the manifest file created for the application ...
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.4053' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
</assembly>
can any one tell what all the files needed to be redistributed with my application
thanks in advance,
Jerin
|
|
|
|
|
Your problem is not simple unfortunately.You would better first use Dependancy Walker to detect dll dependancies and next test your app on guest OS running under Microsoft Virtual PC or VMWare.
Life is a stage and we are all actors!
|
|
|
|
|
Hi
I would like to find function which can chanege a value in data base.
Something like GetFiledValue but which writes value into record
thanks in advance
Rafal
|
|
|
|
|
I can not find a good multiple installation software, so I want to do some test to determine if I can setup installation pack myself:
First question is:
How to add Items to Windows start menu and link user click to related file (exe, chm etc.)?
|
|
|
|
|
Ummm - create a shortcut to the exe or chm in a folder in the start menu - either the All Users start menu (for an 'All Users' install) or the current users start menu. The start menu location can be retrieved with SHGetSpecialFolderPath[^]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
you can send email to me i'm the author kyzhao
|
|
|
|
|
I saw your post on codeproject, and was wondering if you had resolved it. I am having the same issue. My hello world example along with others works fine as an executable, but when I deploy it as a .dll, I can't seem to get it to work.
What I did was this:
The project that contains the CUDA code and generates a .dll builds fine.
CLI project references this unmanaged dll and is essentially just a managed wrapper.
C# project references the managed .dll.
Compiles fine, but i get a runtime file not found error.
When I use Dependency Walker (a nice freeware app) it shows me that MSVCR90D.DLL and DWMAPI.DLL cannot be found, which is strange
because another reference to MSVCR90D.DLL shows the file as found.
Thanks.
|
|
|
|
|
Hi
Following code is from Microsoft (http://support.microsoft.com/kb/243285[^]).
It compiles OK under "debug" using VS2005. It generated warning message under "release".
while ((DWORD)lpHeader &lt; (DWORD)(((LPSTR)lpStart) + size) &amp;&amp; pt != NULL) ;
warning C4311: 'type cast' : pointer truncation from 'LPTTPOLYGONHEADER' to 'DWORD'
warning C4311: 'type cast' : pointer truncation from 'LPSTR' to 'DWORD'
void DrawT2Outline(HDC hDC, LPTTPOLYGONHEADER lpHeader, DWORD size)
{
WORD i;
UINT cTotal = 0;
LPTTPOLYGONHEADER lpStart;
LPTTPOLYCURVE lpCurve;
LPPOINT pt;
POINTFX ptStart;
DWORD dwMaxPts = size/size of(POINTFX);
DWORD dwBuffSize;
dwBuffSize = dwMaxPts *
sizeof(POINT) *
3;
lpStart = lpHeader;
pt = (LPPOINT)malloc( dwBuffSize );
while ((DWORD)lpHeader < (DWORD)(((LPSTR)lpStart) + size) && pt != NULL)
Best regards,
|
|
|
|
|
Well, both of these messages are saying that the original pointers LPTTPOLYGONHEADER and LPSTR are longer than a DWORD, hence the truncation. So there is something in the release version that is set different from the debug. A simple check using sizeof() for each of these types will tell you what size the compiler thinks they should be. That, and checking your compiler project settings for each build type.
|
|
|
|
|
Pointers should be cast to DWORD_PTR , not DWORD . DWORD_PTR changes to match the pointer size of the platform (that's what the "PTR" part means).
--Mike--
Dunder-Mifflin, this is Pam
|
|
|
|
|
transoft wrote: while ((DWORD)lpHeader < (DWORD)(((LPSTR)lpStart) + size) && pt != NULL)
I have just reread this and it seems to me that your casts are redundant. lpStart and lpHeader are both LPTTPOLYGONHEADER types, so they should be comparable without the need for casting. Try rewriting as
while (lpHeader < (lpStart + size) && pt != NULL)
|
|
|
|
|
I'm recently learning C#. In C# you can pass parameters by value or by reference, and as you know, there are value types and reference types in C#.
I don't know if reference in C# means the same thing as in C++. But I think passing a reference type by reference in C# is similar to passing a pointer "by reference" in C++ (Reference to Pointer). As in both cases, the callee can change the values of the object’s state data as well as the object the ref type/pointer is referencing/pointing to.
What do you think?
I've written a program in C++ using "Reference to Pointer".
#include <iostream>
#include <string>
using namespace std;
class Person
{
private:
string name;
public:
Person(string s)
{
name = s;
}
Person()
{
name = "";
}
void SayHello()
{
cout << "Hello, my name is " << name << "!" << endl;
}
};
void Swap(Person *& a, Person *& b)
{
Person *temp;
temp = a;
a = b;
b = temp;
}
int main()
{
Person *p1 = new Person("Alice");
Person *p2 = new Person("Bob");
cout << "Before swapping:" << endl;
p1->SayHello();
p2->SayHello();
cout << endl << "Memory address of *p1:" << p1 << endl;
cout << "Memory address of *p2:" << p2 << endl;
Swap(p1, p2);
cout << endl << "After swapping:" << endl;
p1->SayHello();
p2->SayHello();
cout << endl << "Memory address of *p1:" << p1 << endl;
cout << "Memory address of *p2:" << p2 << endl;
delete p1;
delete p2;
return 0;
}
This program swaps the objects that p1 and p2 points to by passing them to Swap() by reference.
However, if I define Swap() like this:
void Swap((Person *) &a, (Person *) &b)
the compiler would display some error messages.
Swap.cpp(27) : error C2065: 'a' : undeclared identifier
Swap.cpp(27) : error C2065: 'b' : undeclared identifier
Swap.cpp(28) : error C2448: 'Swap' : function-style initializer appears to be a function definition
Swap.cpp(47) : error C3861: 'Swap': identifier not found
I really don't know why there would be errors. Why are those two definitions different?
Finally, I wonder if you know how to do the same swapping job in Java. As you know, in Java I can only pass parameters by value. Do you have any solutions?
|
|
|
|