|
Hi.
Anybody know.
what's function use for convert number between binary and decimal.
|
|
|
|
|
A number is a number whether binary or decimal.
You have to define what you are trying to do before anyone will be able to help.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
|
|
|
|
|
Wes Aday wrote: A number is a number whether binary or decimal.
what about octal?
|
|
|
|
|
octal is so 1980s. I prefer base 7.
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
led mike wrote: what about octal
Well I can only count zero and not zero.... so octal is out of my league....
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
|
|
|
|
|
What is the binary type? Integer? Floating point?
By decimal, do you mean a decimal string?
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
For Example
(binary) (decimal)
00 0
01 1
10 2
11 3
What's function support this issue?
|
|
|
|
|
Ok... watching this could prove entertaining
|
|
|
|
|
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(void){
string bi = "1010"; //binary
int result= 0;
for (int i = 0; i< bi.size(); i++){
if (bi[i] == '1'){
result += pow((double)2,(double)bi.size()-i)/2;
}
}
cout << result << endl;
return 0;
}
that should work
|
|
|
|
|
string sbin("1011");<br />
char* ptr;<br />
long num = strtol( sbin.c_str(), &ptr, 2);<br />
cout << num << endl;<br />
<br />
|
|
|
|
|
oh cool function
|
|
|
|
|
I see we are having another Fish Fillet special [below]
I must horizontally challenged ... below above
Last modified: 1hr 25mins after originally posted --
|
|
|
|
|
That's two mornings in a row I smelled McD's first thing
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi,
I have a program, SDI, with FormView, CGreenView written in vc++6. I have created a subclass of CListCtrl named CMyListCtrl .
Now, when the user right-clicks on the listctrl, a menu pops up with options like 'edit', 'delete' etc. When the user selects 'edit' a dialog pops up and some stuff is done. The coding for the handling the right-click, calling the dialog box is done in CMyListCtrl.
After the dialog box closes, I want to call a function which is written in CGreenView the main view class.
Please can you tell me the right way of doing it?
void CMyListCtrl::OnRecordEdit()
{
if (nItem != -1)
{
CAddNew *pDlg = new CAddNew();
pDlg->type = 2;
Dlg->DoModal();
delete pDlg;
}
}
Thanks.
Fortitudine Vincimus!
|
|
|
|
|
I wouldn't try to call the containing view directly from the contained control. Rather you want to catch the EN_CHANGE or similar message that the control will send to its parent when you commit the changes to it. This will probably turn up at the parent as a WM_NOTIFY and you'll need to pull it apart from there and determine that it came from the control you're interested in and due to the cause you're looking for. Have fun
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thank you very much for the advice.
This what I did.
Its working exacly the way I want it to.
Hope it is correct.
void CMyListCtrl::OnRecordEdit()
{
if (nItem != -1)
{
CAddNew *pDlg = new CAddNew();
pDlg->type = 2;
pDlg->DoModal();
delete pDlg;
LV_DISPINFO lvDispInfo;
lvDispInfo.hdr.hwndFrom = m_hWnd;
lvDispInfo.hdr.idFrom = IDC_FD_LIST;
lvDispInfo.hdr.code = LVN_ENDLABELEDIT;
GetParent()->GetParent()->SendMessage( WM_NOTIFY, IDC_FD_LIST,(LPARAM)&lvDispInfo);
}
else
return;
}
And in the CGreenView class :
void CGreenMView::OnEndlabeleditFdList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
*pResult = 0;
}
Fortitudine Vincimus!
|
|
|
|
|
I've snagged this to open a helpfile for an MFC dialog. For now, it's OK to be just a text file, though at some point an integrated help file / CHM might be better
ShellExecute(this->m_hWnd,"open","notepad.exe","PTW Geske Analyse Help.txt","",SW_SHOW );
Problem is, I am not sure what the paths are involved. It opens notepad correctly but it is not finding the text file. I tried putting it in the same folder as the executable that's launching notepad but to no avail. How can I use a relative path so that if I distribute the program exe and the help file and state that they should be in the same folder, then notepad will correctly find the text file
t.i.a
Lee
ps
have seen ShellExecuteEx but it seemed the extra info (incl. path) refers to the path for notepad and not the target file
PS
it seems to be defaulting to desktop since thats where it saves a new file if promptedm and when I put the txt file there it does indeed open it. Perhaps I need a SetPath type instruction, but I want it to be relative to the running program and not a hard coded path.
|
|
|
|
|
Maybe check out the GetModuleFileName() API and build your full pathname from there...
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
|
ldsdbomber wrote: ShellExecute(this->m_hWnd,"open","notepad.exe","PTW Geske Analyse Help.txt","",SW_SHOW );
change to this :
::ShellExecute(NULL, _T("open"), _T("notepad.exe"), _T("PTW Geske Analyse Help.txt"), <code>NULL</code>, SW_SHOW);
it should whork, unless the PTW Geske Analyse Help.txt file is not found in the application or system path... but you can provide its full path name
|
|
|
|
|
Thanks. This is the kind of thing I keep asking about - which books will teach me how to do things the proper way. I know the _T is a unicode thing isn't it? and the :: is some kind of namespace item, so where can I get a thorough and proper grounding in "good" MFC/C++ from start to finish
|
|
|
|
|
In my dialog based application I want the time and date to appear in the bottom left corner. What is the most efficient way of doing this?
The time and date needs to be displayed exactly as below:
hh:mm:ss
dd-mm-yy
The date and time can only be modfied by clicking on them which will the display a change date and time dialog.
I'm using MS VS2003.
TIA,
Andy
|
|
|
|
|
creating scrollbar....
case WM_CREATE:
sb1 = CreateWindowEx(
0L, // no extended styles
"SCROLLBAR", // scroll bar control class
(LPSTR) NULL, // text for window title bar
WS_CHILD | SBS_HORZ | WS_VISIBLE, // scroll bar styles
50, // horizontal position
20, // vertical position
200, // width of the scroll bar
100, // default height
hwnd, // handle to main window
(HMENU) NULL, // no menu for a scroll bar
hInst, // instance owning this window
(LPVOID) NULL // pointer not needed
);
.............
and then in the message loop:
//-------------------------------------------------
case WM_HSCROLL:{
int xNewPos; // new position
switch (LOWORD(wParam))
{
// User clicked the shaft left of the scroll box.
case SB_PAGEUP:
xNewPos = xCurrentScroll - 50;
break;
// User clicked the shaft right of the scroll box.
case SB_PAGEDOWN:
xNewPos = xCurrentScroll + 50;
break;
// User clicked the left arrow.
case SB_LINEUP:
xNewPos = xCurrentScroll - 5;
break;
// User clicked the right arrow.
case SB_LINEDOWN:
xNewPos = xCurrentScroll + 5;
break;
// User dragged the scroll box.
case SB_THUMBPOSITION:
xNewPos = HIWORD(wParam);
break;
default:
xNewPos = xCurrentScroll;
};
if (xNewPos == xCurrentScroll)
break;
xCurrentScroll = xNewPos;
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS ;
si.nMax = 300;
si.nMin = 0;
si.nPage = 4;
si.nPos = xCurrentScroll;
SetScrollInfo(sb1, SB_HORZ, &si, true);
InvalidateRect( hwnd, NULL, TRUE );
}
//--------------------------------------
the new one shows over the old one. i.e the scrollbar with the height of 100 which i set up
shows over the one with the default height, and dont update. The old one does update when i press the on the new.
visual example, from the code above this happens.
http://i3.photobucket.com/albums/y98/lamefif/scrollbar.jpg[^]
many thanks
|
|
|
|
|
hey folks I've got a simple question:
(No I'm not a newbie and I know what a union is...)
is there any disadvantage (no need for inheritance) of using methods for unions...
I know this is a rare case, but somehow I encountered it.
I figured out I can use methods for unions and it would make it more complicated to put this union into a class (cause the access to the unions-(data-sharing)variables would be less elegant.
thx in advance
zqueezy
some example:
<br />
union matrix4x4<br />
{<br />
__m128 c[4];
float f[16];
vector4 col[4];<br />
<br />
matrix4x4(); <br />
<br />
matrix4x4 operator*(matrix4x4& factor);<br />
};<br />
<br />
|
|
|
|
|
zqueezy wrote: (No I'm not a newbie and I know what a union is...)
hence, IMHO, there are no harms.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|