|
Thanx for the reply...
"....Or kill the second instance and bring the focus on the first instance that was already running? ...."
Yes, I want to send a return code to the calling app (2nd opened application) so that it will see that another instance is already running, kill itself and cause the 1st instance to restore it's window.
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
There could be various solutions to this problem.
Preferrably using mutex's .
something like
HANDLE hMutex;
hMutex = CreateMutex(
NULL, // no security attributes
FALSE, // initially not owned
"SomeUniqueName"); // name of mutex
If this exists already return from the application.
Another option would be to use a shared variable and check for its value. Increment it each time an instance is created. If the value is greater than one you can just return from the second instance.
The third option would be to use the FindWindow function. You would get the handle to the window if it's already running.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
Thanks buddy. Will try and go through this article tomorrow.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanx for the help... I'll try it
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
I am using VC++6.0 and trying to run a demo project about the dialog resources using from <<windows programming="">>.
I copyed its .cpp file, resource.h file into my project, and pasted its .rc file into my .rc file using notepad and add into the project also. But it didn't work,and pop out these errors:
--------------------Configuration: mymenu - Win32 Debug--------------------
Compiling...
mymenu.cpp
E:\work\project\mymenu\mymenu.cpp(20) : error C2065: 'IDC_BLACK' : undeclared identifier
E:\work\project\mymenu\mymenu.cpp(22) : error C2065: 'IDC_RECT' : undeclared identifier
E:\work\project\mymenu\mymenu.cpp(195) : error C2065: 'IDM_APP_ABOUT' : undeclared identifier
E:\work\project\mymenu\mymenu.cpp(195) : error C2051: case expression not constant
E:\work\project\mymenu\mymenu.cpp(203) : warning C4060: switch statement contains no 'case' or 'default' labels
E:\work\project\mymenu\mymenu.cpp(257) : error C2065: 'IDC_WHITE' : undeclared identifier
E:\work\project\mymenu\mymenu.cpp(259) : error C2065: 'IDC_ELLIPSE' : undeclared identifier
E:\work\project\mymenu\mymenu.cpp(263) : error C2065: 'IDC_PAINT' : undeclared identifier
E:\work\project\mymenu\mymenu.cpp(299) : error C2051: case expression not constant
E:\work\project\mymenu\mymenu.cpp(301) : error C2065: 'IDC_RED' : undeclared identifier
E:\work\project\mymenu\mymenu.cpp(301) : error C2051: case expression not constant
E:\work\project\mymenu\mymenu.cpp(303) : error C2065: 'IDC_GREEN' : undeclared identifier
E:\work\project\mymenu\mymenu.cpp(303) : error C2051: case expression not constant
E:\work\project\mymenu\mymenu.cpp(305) : error C2065: 'IDC_YELLOW' : undeclared identifier
E:\work\project\mymenu\mymenu.cpp(305) : error C2051: case expression not constant
E:\work\project\mymenu\mymenu.cpp(307) : error C2065: 'IDC_BLUE' : undeclared identifier
E:\work\project\mymenu\mymenu.cpp(307) : error C2051: case expression not constant
E:\work\project\mymenu\mymenu.cpp(309) : error C2065: 'IDC_MAGENTA' : undeclared identifier
E:\work\project\mymenu\mymenu.cpp(309) : error C2051: case expression not constant
E:\work\project\mymenu\mymenu.cpp(311) : error C2065: 'IDC_CYAN' : undeclared identifier
E:\work\project\mymenu\mymenu.cpp(311) : error C2051: case expression not constant
E:\work\project\mymenu\mymenu.cpp(313) : error C2051: case expression not constant
E:\work\project\mymenu\mymenu.cpp(325) : error C2051: case expression not constant
E:\work\project\mymenu\mymenu.cpp(327) : error C2051: case expression not constant
Error executing cl.exe.
mymenu.exe - 23 error(s), 1 warning(s)
|
|
|
|
|
"undeclared identifier" it seems you need to include a header file to mymenu.cpp did you include this file?
|
|
|
|
|
yes, as you can see in .cpp file, I had
#include <windows.h>
#include "resource.h"
|
|
|
|
|
check the Ignore HTML tags in this message (good for code snippets) check box
|
|
|
|
|
sure you include but i cant see header file in previous your thread i saw only #include:) anyway these erros are only a thing a include
|
|
|
|
|
Hello everybody,
I've figured out that windows supplies an smart way to draw cutom elements via DrawFrameControl.
When drawing a radio button or a checkbox the question is where to place the text exactly. Of course it is no problem to figure out the settings for the standard settings (MS Sans Serif 8), but I wonder the windows internal logic for other fonts and sizes. I've used a lot of time to consider all values of GetTextMetrics, but I was not success full.
Has anybody found a rule where the text is placed exactly depending on font and font size?
|
|
|
|
|
now whats your problem?
|
|
|
|
|
Maybe the easisiest ways is to use some code to show my problem on drawing the radio button.
PaintRadioButton(CDC* pDC, const CRect& rcPos, const CFont& font, const CString& strText)<br />
{<br />
DWORD dwBackground = GetSysColor(COLOR_BTNFACE);<br />
CBrush brushBk(dwBackground);<br />
pDC->FillRect(rcRadioButton, &brushBk);<br />
<br />
CRect rcCircle;<br />
CalcCircleRect(rcPos, rcCirlce);<br />
pDC->DrawFrameControl(rcCircle, DFC_BUTTON, DFCS_BUTTONRADIO);<br />
<br />
CalcTextRect(rcPos, rcText, font, strText);<br />
pDC->DrawText(strText, rcText, DT_LEFT|DT_VCENTER|DT_SINGLELINE);<br />
<br />
}
CalcCircleRect(const CRect& rcPos, CRect& rcCirlce) is easy to implement, just center the box vertically and make an offset of 1 in the horicontal position. The size could be received through GetSystemMetrics(SM_CXMENUCHECK);
CalcTextRect(const CRect& rcPos, CRect& rcTextPos, cont CFont& font, const CString& strText) Is the thing what is missing. Do you know some magic formula how to calculate the exact position for the text depending on font, font size and text content so it looks exactly like the radio button controls?
|
|
|
|
|
Hello everyone,
Yahoo is using a technology called sign-in seal to protect password stolen. Check,
[url]http://mail.yahoo.com[/url]
[url]http://help.yahoo.com/l/us/yahoo/edit/privacy/edit-39.html[/url]
Does any one know what it is and whether there are any documents/SDK supporting that feature? I have Googled, but only can find advertisements ...
thanks in advance,
George
|
|
|
|
|
Hi All,
Can someone suggest a good site to study about IOCTL's From start.
I also have another doubt. Are IOCTL's predefined by VC++ or user defined.
I need a clear understanding of this. Plz Someone help me.
Thanks and Regards in Advance
Kenny
|
|
|
|
|
I would suggest Googling for device driver development under Win32.
I also believe that you can define your own IOCTLs in your own driver.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi all,
Can Someone tell me How to set the color for button control, both at design time and runtime?
Thanks and Regards in Advance
Kenny
|
|
|
|
|
Derive a class from CButon
Class ButonEx: public CButton
{
------
------
}
override the DrawItem(....)
void ButonEx::DrawItem( LPDRAWITEMSTRUCT lpDIS_i )
{
CDC DCItem;
DCItem.Attach( lpDIS_i->hDC );
// Use this DCItem to select different objects ...also set text color and all
}
Rinu Raj
|
|
|
|
|
After derived CButton insert WM_DRAWITEM and see snippet code(you can see a lot of examples about CButton on codeproject)
<br />
void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)<br />
{<br />
CDC dc;<br />
dc.Attach(lpDrawItemStruct->hDC);<br />
<br />
UINT state = lpDrawItemStruct->itemState; <br />
<br />
dc->FillRect(lpDrawItemStruct->rcItem<br />
,&CBrush(RGB(255,255,255)));<br />
dc->SetTextColor(RGB(0,0,0));<br />
<br />
CString str;<br />
GetWindowText(str);<br />
dc->DrawText(str,rect,DT_CENTER|DT_SINGLELINE);<br />
...<br />
...<br />
}<br />
|
|
|
|
|
Gday everyone,
I'd like to display recent received messages in the buffer 'msg_cat' when user types in 'display', but it always displays 'No recent messages' after I concatenated messages into 'msg_cat'. I use global buffer 'msg_cat'. Is there something wrong of the way I use 'msg_cat'? Or the affect of using fork function in main?
I spent so much time on time, but I really don't know how to fix this problem.
It really depends on you guys experts here. Please help me out if you're interested in this.
I'd appreciate it.
char msg_cat[1000];
void displayMulticastedMessage(int condition){
char *msg;
int stop = -1;
if (condition == 2){
if (strcmp(msg_cat, "") != 0){
printf("msg_cat: %s", msg_cat);
strcpy(msg_cat, "");
}
else{
printf("No recent messages\n");
}
}
while(stop < 0){
msg = (char *)recvfromDST (&read_EP, sockMulti);
strcat(msg_cat, msg);
strcat(msg_cat, "\n");
if (msg != NULL){
printf("----- Waiting for Multicasted message ----- \n");
printf("\nReceived multicast message ==> %s \n", msg);
}
else{
stop = 0;
}
}
}
void receiveUserMessage(int sock){
int stop = -1;
char *msg;
while (stop < 0){
printf("Type message or 'display' to display recent multicasted messages or 'end' to quit \n");
scanf ("%s", KB_buff);
if (strncmp(KB_buff, "display", 7) == 0){
int display = 2;
displayMulticastedMessage(display);
}
else{
int stop = sentMessage(KB_buff,sock);
}
printf("\n");
}
}
int main(){
if (pid == 0)
{
receiveUserMessage(MC_socket);
}
else
{
if (pid < 0)
{
perror("fork");
exit(1);
}
else
{
int user = -1;
displayMulticastedMessage(user);
}
}
}
eric
|
|
|
|
|
Hi,
I am recording a .wav file using the headphones.The file gets saved but i get a noise(clicking sound) which is consistent along the the recorded voice.The noise(Clicking sound) starts when the recorded file is open and remains until the file is fully read.
Can any1 tell me how to go about in removing this noise(clicking sound) from the .wav file which is created.
I am coding using C in the VC++ environment.
Thanks...
Riz
|
|
|
|
|
There is no need to repost. If you didn't get an answer the first time, then it is doubtful that anybody here is able to help you. Perhaps you could try searching google for an audio forum where the members would have more knowledge about your topic.
|
|
|
|
|
It could be that your buffer size for recording is not completely filled before you save (example - you allocate 1024 samples per buffer, you capture 1023 samples in each buffer, but you save 1024 samples per buffer into the file), or there is a gap between recorded buffers (example - your sampling rate is 22 kHz, your buffers each have 1000 samples, but you only capture 20 buffers per second.)
Have a look at the wav file you have saved using a wave editor (something which can show you the actual samples in the wav file) and see if the value regularly drops to zero, or if it regularly jumps. Usually these jumps will occur at the rate determined by your buffer length.
Alternatively, it could be caused by your sound card drivers. I had significant problems with audio capture using the default WinXP drivers (some onboard VIA sound I think - I don't remember details) - update your audio drivers and try again.
|
|
|
|
|
how can I add one date with a number of days to have another date.
For example: 09/18/2006 + 30 days
|
|
|
|
|
use CTime and CTimeSpan
nave
|
|
|
|