|
yes it is exactly that 9--->september
|
|
|
|
|
zizzzz wrote: I want to have 09 (2digits) because i need it in this format
can you help me
you should read format specifier
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi all,
OK, so lets say you have an application, lets call it app1. app1 may not have more than one process running at one time. And if another process was found restore the previous app1. This is where the problem comes in.
See the thing is the the second instance of app1 has been opened and the app sees that another instance is running (of itself), how will it diffrenciate between the two app window names, to bring the correct one to the foreground??
Really Hope this makes sense
Any ideas???
Thanx in advance
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
actually, it does use a semaphore/mutex, which name must be unique.
see this[^] class to understand what it actaully does.
|
|
|
|
|
Programm3r wrote: app sees that another instance is running (of itself)
So do you want to keep the second instance also running?
Or kill the second instance and bring the focus on the first instance that was already running?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
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
|
|
|
|