|
Use the IsTextUnicode() function. But see this function is not foolproof. Read what the documentation[^] says.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Not sure if it is possible, but is there a way to evaluate the String's XCHAR type at runtime? Conceptually, something like:
if( sizeof( m_str::XCHAR ) == sizeof( wchar_t ) ) { Unicode };
if( sizeof( m_str::XCHAR ) == sizeof( char ) ) { ANSI }; But I am not that familiar with the new CString classes to be able to help further.
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,
First of all, I would like apologize for creating a new thread, but I'm getting desperate.
This is the scenario:
I have this structure:
<br />
static struct<br />
{<br />
int ConnectSock;
int ConnectState;
ULONG BytesTrans;
ULONG FileLength;
ULONG TimeMark;
char Request[STRING_SIZE];
char FileName[STRING_SIZE];
char PathName[STRING_SIZE];
char PCName[STRING_SIZE];
ULONG BytesRec;
} gConnectData[MAX_CONNECT];<br />
Before I populate the PCName variale, I do the following, get an open slot for the next connection:
<br />
int FindFreeSlot(void)<br />
{<br />
int i, s;<br />
for(i=0;i<MAX_CONNECT;i++)<br />
{<br />
s = gConnectData[i].ConnectSock;<br />
if(s==-1)<br />
return i;<br />
}<br />
return -1;<br />
}<br />
main()<br />
{<br />
...<br />
while(1)<br />
{<br />
i = FindFreeSlot();<br />
...<br />
}<br />
}<br />
I when populate the PCName variable of the structure with data:
Please note that the for loop is part of the while loop.
<br />
for(i=0;i<MAX_CONNECT;i++)<br />
{<br />
...<br />
strcpy((char*)gConnectData[i].PCName,(char*)strDest);<br />
...<br />
}<br />
Ok, I'll try an explain this the best I can:
The thing is that the variable i does not move in a sequence (because of the server having to know which connection it's communicating with), for instance if I print the following the output would be:
<br />
strcpy((char*)gConnectData[i].PCName,(char*)strDest);<br />
printf("\n### Connection Sock -> %d Int Value -> %2d PC NAME VALUE -> %s\n",Sock,i,(char*)gConnectData[i].PCName);<br />
Connection Sock -> 0 Int Value -> 0 PC NAME VALUE -> PCOne
next cycle
Connection Sock -> 1 Int Value -> 1 PC NAME VALUE -> PCTwo
next cycle
Connection Sock -> 1 Int Value -> 1 PC NAME VALUE -> PCOne
Does it make sense
Can anyone help??
Many thanx in advance
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Never mind .... I got it working ....
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
anyway, keep thinking to use the <pre></pre> tags to post code samples
|
|
|
|
|
Hi!
I´m using the Windows Forms Template and found some, in my oppinion, odd behaviour. Whenever I add something like an event to a component it´s added in the header file.
Aren´t those header files just supposed to hold declarations of methods etc?
The following is a snippet of the generated code in Form1.h:
#pragma endregion<br />
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {<br />
}<br />
private: System::Void dateTimePicker1_ValueChanged(System::Object^ sender, System::EventArgs^ e) {<br />
mopped->Text = dateTimePicker1->Value.ToLongDateString();<br />
}<br />
private: System::Void dateTimePicker1_Enter(System::Object^ sender, System::EventArgs^ e) {<br />
MessageBox::Show("Das ist ein Test");<br />
}
This code doesn´t really do anything and is just an attempt to fiddle out how things work in VS Express C++.
Well I hope someone is able to understand what I mean (in respect to my germanish english) .
Thanks,
Michael
|
|
|
|
|
C++/CLI tends to put it all in the .h, which is valid C++. I believe you can move it without problem to the .cpp.
Christian Graus - C++ MVP
|
|
|
|
|
Hi all, i have a tree control in which i want to show the
popup menu when someone right clicks on item.
so that i hadled the NM_RCLICK message but the pop up menu comes
somewhere near start button!!
the code is as follows
void CTreeViewDlg::OnNMRclickTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
NM_TREEVIEW* pNmTreeVew = NULL;
pNmTreeVew =(NM_TREEVIEW*) pNMHDR;
if(pNmTreeVew)
{
CPoint point;
point.x = pNmTreeVew->ptDrag.x;
point.y = pNmTreeVew->ptDrag.y;/*
HMENU hMenu = LoadMenu(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_MENU1));
if(hMenu)
{
TrackPopupMenu(hMenu,0,point.x,point.y,0,pTreeCtrl->m_hWnd,NULL);
}
}
}
What can be the problem with this code?
actually when i debugged the code it point.y shows some big value
so please tell what is the problem
Thanks and regards
Harshal
|
|
|
|
|
Hi,
it retrieves you coordinates for the screen and you need convert it to client. Use ScreenToClient method of treectrl:
void ScreenToClient(
LPPOINT lpPoint
) const;
-----------
Mila
|
|
|
|
|
I have done it this way but still it shows the menu
at same position.
|
|
|
|
|
Try GetMessagePos():
...
point = (CPoint) GetMessagePos();
tree->ScreenToClient(&point);
In my case works fine.
-----------
Mila
|
|
|
|
|
void CTreeViewDlg::OnNMRclickTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
CPoint ptMouse;
DWORD dwPos;
UINT nFlags;
CTreeCtrl *pTreeCtrl;
pTreeCtrl = (CTreeCtrl *)GetDlgItem(IDC_TREE1);
{
dwPos = ::GetMessagePos();
ptMouse.x = LOWORD (dwPos);
ptMouse.y = HIWORD (dwPos);
CPoint ptAction = ptMouse;
// convert coordinates
pTreeCtrl->ScreenToClient(&ptAction);
// determine if click is on tree item
HTREEITEM hItemRClick = pTreeCtrl->HitTest(ptAction, &nFlags);
// if click is on tree item,
if (hItemRClick != NULL)
{
// set selection to right+clicked item
pTreeCtrl->SelectItem(hItemRClick);
HMENU hMenu = LoadMenu(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_MENU1));
if(hMenu)
{
hMenu = GetSubMenu(hMenu,1);
if(hMenu)
{
TrackPopupMenu(hMenu,0,ptMouse.x,ptMouse.y,0,pTreeCtrl->m_hWnd,NULL);
}
}
}
}
*pResult = 0;
}
i have done something like this
Noe the pop up menu is poping up
but whenever i click on something it does not go to respective
handler!!
Thanks and regards
Harshal
|
|
|
|
|
I think the pNMHDR argument of your handler actually does not point to NMTREEVIEW structure. (See the documentation of NM_RCLICK in case of tree controls). But you can obtain the current cursor position using GetCursorPos function:
CPoint point;
GetCursorPosition(&point);
I hope this helps.
|
|
|
|
|
2 questions
(1)how to get difference when user loads a file from "Open file" and "Recent fil" - or, how to know if user clicks a "Recent file" rather than "Open file"?
In my app, I used a setteing (or check register) to record "recent files", I think it is not a good way.
(2)how to change maximum allowed count of "recent files"?
|
|
|
|
|
1 => the function AddToRecentFileList of the application is automatically called by the document to complete the MRU (Most Recent Files) file list
when the application open a MRU file, the function OnOpenRecentFile is called by the application class
2 => in your class application::InitInstance there's the fuction LoadStdProfileSettings(5) which is called. This define the number of MRU
|
|
|
|
|
Hi,
I have a requirement to keep an application alive even after an user logs off. i.e When the second user logs in, the applications that are opened by the first user should remain open. Is there any way to do this? As our appication would take more time to shutdown and startup we dont want to close it while log off.
Can anybody help me out in resolving this...
An another thing i dont want run my application as a service ...
Is it possible to hibernate the application and wake up when the next user logs in?
Can anybody tell me the concept of Identity Switching? Can this be employed to solve this issue?
What happens when the Switch user is being called in Windows XP? Is there any API to accomplish this task?
Platform : Windows
Thanks,
Selva
-- modified at 4:25 Tuesday 21st November, 2006
~ Selva
|
|
|
|
|
SelvaKr wrote: to keep an application alive even after an user logs off. i.e When the second user logs in, the applications that are opened by the first user should remain open
I think you need to wrote a windows service application. Good luck!
|
|
|
|
|
Thanks for your reply Moga...
But i dont want to keep my app as a service...Any other way apart from this...
Is there any other way like XP's hibernation technique or only changing the user identities ....
Thanks.
~ Selva
|
|
|
|
|
If you detect that your app is being closed, and store it's state to a local file, you can read it again when the app opens. You would have to do something fairly funky for it to work like hibernation.
Christian Graus - C++ MVP
|
|
|
|
|
Hi Graus,
Thanks for your reply.
But this approach will again require all my supporting dlls to load again which will lead in time consumption again
Or is it possible to switch the identities of all the running applications instead of logoff/login. Will it change the user privilege of windows too?
Thanks.
~ Selva
|
|
|
|
|
SelvaKr wrote: Or is it possible to switch the identities of all the running applications instead of logoff/login. Will it change the user privilege of windows too?
No, that's not going to work.
Christian Graus - C++ MVP
|
|
|
|
|
SelvaKr wrote: An another thing i dont want run my application as a service
Why not? A service is exactly the solution to what you're asking.
SelvaKr wrote: Is it possible to hibernate the application and wake up when the next user logs in?
Why build your own keep-alive system when the OS already has one? I suppose you could make your app persist its state to a file, then read it back in on the next launch. But then it's not actually running after logoff.
|
|
|
|
|
Did you try to add a key in the following registry path "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" to automatically start your application for all users ?
|
|
|
|
|
Thanks for your reply..
But my app should not be closed while logoff..
I dont want to start it for each login since it would take more time to load.
~ Selva
|
|
|
|
|
I see 2 solutions :
- Create a service : I know that you dont want to do this...but a service is not closed on logoff
- Use the Run Registry Key to launch your app for each logon and optimize the applicatino loading
|
|
|
|