|
Hi everyone.
Please guide me how I can save following information in a bit Array.
I have different level context Menu. I want to store level information, Item ID, Position and Enable/Disable in one bit sequence.
For example:
241 ID_FILE_PRINT 3 1
2 is First Menu
4 is Sub Menu of First Menu
1 is Sub Menu of Sub Menu at 4
ID: ID of Item
3 is position at Sub Menu 1
1 is enable/disable bit
Please guide me how can i store all the information in an bit Array. How can i get specific value out from the built bit sequence.
Your help is highly appreciated.
Thank you.
|
|
|
|
|
The modern C++ way to do this with is with C++ Bit Fields.[^]
Here is an example:
typedef struct _BitArray
{
unsigned bit1:1;
unsigned bit2:2;
unsigned bit3:3;
unsigned bit4:4;
unsigned bit5:5;
unsigned bit6:6;
unsigned bit7:7;
unsigned bit8:8;
} BitArray, *LPBitArray;
TRACE1("Size of type = %d",sizeof(_BitArray));
BitArray b = {0};
b.bit1 =1;
Best Wishes,
-David Delaune
|
|
|
|
|
Thank You Dear.
destined to win
|
|
|
|
|
Good Morning !
I have four radio buttons in the main dialog box, each radio button refers to a sub application, once the user selects one radio button all the four buttons are disabled when the user completes the work in the sub application he comes back to the main dialog box which has four radio buttons all are in disabled form , now i enable them so that user can select a different sub application, but the previously selected radio button is still selected, so how to unselect the previously selected radio button ??
thanks !
|
|
|
|
|
The radio buttons should be arranged in a group so that if the selection changes for either of the radio button the other one automatically gets deselected
See here[^]
You don't need to do it explicitly
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanks but couldn't get it!!
i just need to select and unselect programmatically, using the object of the radio button!!
|
|
|
|
|
kapardhi wrote: i just need to select and unselect programmatically, using the object of the radio button!!
If this is the way you want here is the API that you can use.
void CButton::SetCheck(int nCheck );
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
..................
How Can I get running processes of WinXp.
I need to do one function execution if the process is running,
..caan u plz tel me whats the WindowsAPI for this.
waiting for ur reply.
|
|
|
|
|
Member 3220373 wrote: How Can I get running processes of WinXp.
BOOL EnumProcesses(DWORD* lpidProcess,DWORD cb,DWORD* cbNeeded);
Eg from MSDN:
void PrintProcessNameAndID( DWORD processID )
{
char szProcessName[MAX_PATH] = "unknown";
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
if (NULL != hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
}
else return;
}
else return;
printf( "%s (Process ID: %u)\n", szProcessName, processID );
CloseHandle( hProcess );
}
void main( )
{
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return;
cProcesses = cbNeeded / sizeof(DWORD);
for ( i = 0; i < cProcesses; i++ )
PrintProcessNameAndID( aProcesses[i] );
}
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thankx...
But actually I need to check only one condition that..
one of my process( eg. wmplayer.exe) is running then
i have to execute my statemnt.
but this code is quite large for my need..
can u give any small code or API so that I can check its Proces Name/Caption that a normal user can know..
plzzzzzzzzzzzzzzzz I need ur Help...
Thanx once again..
I m waiting..
|
|
|
|
|
You can filter the code since now you have the API's you would need to achieve this.
Alternatively, you can try using BOOL IsProcessInJob(HANDLE ProcessHandle,HANDLE JobHandle,PBOOL Result);
Pass JobHandle as NULL and you can get if the process is running under any job.
Haven't tried this, but it should work and suffice your needs.
Let me know if it helped.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanxxxxxxxx...
Its working in Visual Studio 2005.
but how can i use it in visual studo 6.0.
It shows error for psAPI.h file is not found.
|
|
|
|
|
google for psapi.dll, the best place to put the file is in your system32 folder and then link to this library. hope this helps
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
Member 3220373 wrote: one of my process( eg. wmplayer.exe) is running then
i have to execute my statemnt.
If you just want to check if the process is running
Does GetProcessID[^] help?
Regards,
Sandip.
|
|
|
|
|
Hi again I was wondering if somebody could help me with this program I cant get it to stop displaying 32 so that I can check if the program actually works. here is my code. Thanks in advance if anyone can help
// LanusPassword.cpp : Defines the entry point for the console application.
//Corey Lanus
//Program # 10
//Lanus Password
//Verifies that the password meets the requirements
//November 10, 2008
#include "stdafx.h"
#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;
int main()
{
const int size=10;
string pass;
int length;
int caps=0;
int num=0;
int low=0;
cout << "Please enter a 10 character password.\n";
cout << "You must make sure your password has at\n";
cout << "least two uppercase and at least one\n";
cout << "lowercase letter and atleast 1 number.\n";
cin >> pass;
length = sizeof(pass);
cout << length <<endl;
while (length != 10)
{
cout << "You can only enter 10 characters. Please type again.\n";
cin >> pass;
length = sizeof(pass);
}
for (int cnt=0; cnt<size;>{
cout << pass[cnt] << " ";
}
// New line
cout << endl;
for (int i=0; i<size;>{
cin >> pass[i];
if (isdigit(pass[i]))
num=num+1;
if (isupper(pass[i]))
caps=caps+1;
if (islower(pass[i]))
low=low+1;
}
while (caps<2 || low < 1 || num < 1)
{
num=0;
caps=0;
low=0;
cout << "You must make sure your password has at\n";
cout << "least two uppercase and at least one\n";
cout << "lowercase letter and atleast 1 number.\n";
cin >> pass;
for (int i=0; i<size;>{
cin >> pass[i];
if (isdigit(pass[i]))
num=num+1;
if (isupper(pass[i]))
caps=caps+1;
if (islower(pass[i]))
low=low+1;
}
}
cout << "Your password: " << pass << ", is good and excepted.\n";
return 0;
}
|
|
|
|
|
LilKoopa wrote: while (length != 10)
Your code would only work if the length of the "pass" string is returned as 10. You need to check the condition in the while loop first
LilKoopa wrote: cout << length <<endl;
This line, above the while loop would be printing 32 ie the size of pass variable since the length would always be greater than 10
LilKoopa wrote: so that I can check if the program actually works
I hope that you can now check the program after modifying the condition for the while loop
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
sizeof(pass) always returns 4 - it's returning the size in bytes of the pointer that points to the string, not the actual length of the string itself..
if you change
string pass;
to
char pass[100];
and all occurances of
sizeof(pass)
to
strlen(pass)
You'll get code that correctly counts the number of letters in the password. The logic in your code then gets a bit funky, and I can't quite tell what you're trying to do there. Often things become much more clear when you separate out the individual parts of a problem into their own functions.
Might I suggest a different approach to this problem?
#include <iostream>
using namespace std;
int countNumChars(char *str)
{
}
int countLowerChars(char *str)
{
}
int countUpperChars(char *str)
{
}
bool isValidPassword(char *password)
{
int len, numberChars, lowerCaseChars, upperCaseChars;
bool result = false;
len = strlen(password);
numberChars = countNumChars(password);
lowerCaseChars = countLowerChars(password);
upperCaseChars = countUpperChars(password);
result = ((len==10)&&(lowerCaseChars>=1)&&(upperCaseChars>=2)&&(numberChars>=1));
return result;
}
int main()
{
char pass[100];
cout << "Please enter a 10 character password.\n";
cout << "You must make sure your password has at\n";
cout << "least two uppercase and at least one\n";
cout << "lowercase letter and at least 1 number.\n";
cin >> pass;
while (!isValidPassword(pass))
{
cout << "Invalid Password. Please type again.\n";
cin >> pass;
}
cout << "Your password: " << pass << ", is good and accepted.\n";
system("pause");
return 0;
}
|
|
|
|
|
Hi,
Before this, I managed to compile my CSP code and its already work in XP. The step that I take was:
1-compile my csp program- Visual Studio 2005
2-replace the advapi32.dll (for xp)
3-register the dll
--> copy the dll to system32
--> register the dll -regsvr32 xxx.dll
The problems comes when I want to build the CSP in Vista platform. Currently I'm using Vista Ultimate.
I can compile my csp program - Visual Studio 2005.
But, I cannot replace the advapi32.dll for Vista platform in Windows\System32.
I got error:
Destination Folder Access Denied
- You need permission to perform this action.
But I still try to register the dll-I got the error :
CryptAcquireContext returned error 80090019
Do you have any idea on how to solve this problem? What I mean is how to develop the CSP in Vista?
Thank You.
regards,
Yani
|
|
|
|
|
HI,
I am doing visual c++ 2003, and I want to ask about how to convert the data type format ( TotalSeconds) to date format, I know how to convert from date format to total seconds but how to convert in the reverse way, I don't know
this is the way that I convert from date format to total seconds
Ctime Now = CTime::GetCurrentTime();
CTime UCT(0);
CTimeSpan Diff = Now - UCT;
return Diff.GetTotalSeconds();
but how to convert in the reverse way
I would be grateful if you guys can help me
Regards,
Arif Liminto
|
|
|
|
|
arifliminto86 wrote: but how to convert in the reverse way
I am not sure that I understand your question but I believe that you are asking how to convert a 64 bit integer containing CTime total seconds back into a CTime object. If this is what your looking for then perhaps the following code will help.
CTime tNow = CTime::GetCurrentTime();
OutputDebugString(tNow.Format(_T("Current Time: %A, %B %d, %Y\n")));
LONGLONG i64TotalSeconds = tNow.GetTime();
CTime tBack(i64TotalSeconds);
OutputDebugString(tBack.Format(_T("Converted Time: %A, %B %d, %Y\n")));
Best Wishes,
-David Delaune
|
|
|
|
|
Store your number of seconds in a time_t variable and pass it to one
of the functions that takes a time_t (or time_t *); then process the
result.Eg
int main ()
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( "The current date/time is: %s", asctime (timeinfo) );
return 0;
}
Hope it helps
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
Hello, can anyone give me a suggestion about how can I draw my windows application without the windows system border? Like those Yahoo widget which floating in the desktop? Which GUI SDK support this feature? Thanks!
Nacho
|
|
|
|
|
It's just a matter of the style used when the call to CreateWindowEx is made.
If I use a style of WS_VISIBLE|WS_POPUP|WS_SYSMENU|WS_MINIMIZEBOX
and a styleEx of WS_EX_APPWINDOW
I get a window without a border, that has an entry on the task-bar and who may be minimized or closed from the system-menu, activated by right-clicking the task-bar entry for the program.
See this project for a quick demo: Clock Application[^]
|
|
|
|