|
it won't work for that number because the value being returned is an int and range for int's is upto 32767 and while performing the calculations the number (value "binary" being returned from that function) exceeds the limits. ie why I said that this technique is quick and dirty . OPTIMIZE it
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
chandu004 wrote: does it work for 1024?
void DecimalToBinary(int number) {
int value;
if(number <= 1) {
cout << number;
return;
}
value = number%2;
DecimalToBinary(number >> 1);
cout << value;
}
Now it would............ and now don't say that it won't work for a negative number :->
Just do some error handling. I hope that this does work for you
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
did you know that itoa() was doing that kind of stuff by itself ?
|
|
|
|
|
_AnShUmAn_ wrote: and this function does have its limitations.
It's a good thing, too. Otherwise you would have quickly realized your function does not "convert" its argument to base-2. The function will need to return some sort of char* or string in order to properly represent a base-2 number.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
This thread is like a fishing derby
|
|
|
|
|
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I've noticed a pattern ... Given my timezone in relation to most posts, every morning I
read through all last night's posts. There's mostly posts with 10 to 100+ fishing-derby-style
replies and then the one lonely reply by DavidCrow (or led mike) at the end with a one line simple
solution It's like a train wreck - I can't help but read them all LOL
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
|
Hi,
I know that it is possible to "protect" your application so that you can just see the top-level window of an app if you use Spy++ or similar. All child windows arent listed there (like Edit boxes, checkboxes etc).
If I want to get the state of a checkbox, the normal Message BM_SETCHECK is not usable.
What are the ways to protect the apps and is there a wor around to be able to send messages and get the state of a checkbox or read the text of an editbox?
Thats what I used so far for nonprotected apps:
#include "stdafx.h"
using namespace std;
#define TEXT_LENGTH 1024
char text[TEXT_LENGTH+1];
HWND hwndInfo = NULL;
HWND hwndEdit = NULL;
BOOL CALLBACK EnumChildWindowsProc(HWND hWnd, LPARAM lParam)
{
char pcControlClass[TEXT_LENGTH];
GetClassName(hWnd, pcControlClass, TEXT_LENGTH);
if( ::strcmp(pcControlClass, "Edit") == 0 )
{
TCHAR pcEditText[TEXT_LENGTH];
long len = SendMessage(hWnd, WM_GETTEXT, TEXT_LENGTH, (LPARAM)pcEditText);
if( len != 0 )
{
SendMessage(hWnd, WM_SETTEXT, TEXT_LENGTH, (LPARAM)"lala");
}
return false;
}
return true;
}
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
char pcWinTitle[TEXT_LENGTH];
if( !::GetWindow(hWnd, GW_OWNER) )
{
::GetWindowText(hWnd, pcWinTitle, TEXT_LENGTH);
if( ::strcmp(pcWinTitle, "HookTest123") == 0 )
{
EnumChildWindows(hWnd, EnumChildWindowsProc, (LPARAM)0);
return false;
}
}
return true;
}
int _tmain(int argc, _TCHAR* argv[])
{
EnumWindows( EnumWindowsProc, (LPARAM)0);
return 0;
}
|
|
|
|
|
|
i am having an excel sheet and i want to get the sheet name through the code.... is there any way for that
|
|
|
|
|
philiptabraham wrote: is there any way for that
Have you considered Excel Automation?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I have 5 projects say project1, project2...and project5. I want to compile these projects to my will as below when i try to build the entire work space.
First it has to buile project5,
then project3,
then project4
then project1 and
then project2.
all the projects are in the same work space in VS 2005.
I think we can do this is different ways...but I never tried any of this..so suggest me with is the best way.
1) Creating a BATCH FILE to compile the each project seperatly
2) Using MAKEFILE
3) May be..by doing some setting changes.
or any other way is avilable??
Thanks in advance,
Nandu.
|
|
|
|
|
In the VSMain Menu there are options for it Project -> Project Build Order.
With works fine.
Greetings from Germany
|
|
|
|
|
Thank you very much...it helped me a lot.
Nandu
|
|
|
|
|
In general, the only time where project build order is important is when one (or some) project(s) depends on other projects in the solution. For example when one project is a library that is used by the other project in the solution.
In that case, the easiest way to specify that is by configuring properly the Project dependencies ('Project' -> 'Project Dependencies'). You will need to configure that for each project and specify on which it depends.
The build order will then automatically configured.
|
|
|
|
|
Windows 95 only: The nItems parameter is limited to 16-bit values. This means list boxes cannot contain more than 32,767
So above W95 is it supposed to work with let's say app. 60 000 items? Because on XP it doesn't seem to be working correctly. It displays the items, but I also use itemdata pointers. The getcount() doesn't return the correct number of items...
Anybody dealt with something similar?
|
|
|
|
|
u mean u are not getting it in 95 or xp.
any way try using something like getcountex()
|
|
|
|
|
The first sentence is from MSDN.
I use XP, so thought it should work, but it gives incorrect result.
getcountex? with listbox? that function doesn't seem to exist on vc++ ...
|
|
|
|
|
does it even fail for less number of items?
|
|
|
|
|
tuxyboy wrote: It displays the items...
All 60,000 of them? If so, how are you using the GetCount() method?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi All,
I would like to place a button on the right hand side of all list box items.
Can anybody have some idea...
Thanks!
|
|
|
|
|
you have to subclass the list control.. CP contain many article relating to it.. just search TEXT "SUBCLASS"
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You have to create the buttons (parent should be listbox) and place it dynamically.
- NS -
|
|
|
|