|
That's the easy part. Now how do you determine where the user authenticated? (i.e. local host, NT Domain, etc.)
I need the "context" of the user's authentication.
Thanks for the reply...good quote...
--AJ
PS: I see a "GetUserNameEx" for Win2K and later...it would do what I need (I think), but I need some kind of compat. with NT4 and probably Win98 as well.
|
|
|
|
|
The follwing KB articles may be helpful:
Q111544 HOWTO: Retrieve Current User and Domain Names on Windows NT
Q155698 HOWTO: Retrieve Current User and Domain Names on Windows 95 and Windows 98
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
PERFECT!
Thanks.
--AJ
|
|
|
|
|
How do to move the cursor ("|") into a CEdit?
Thanks
|
|
|
|
|
Assuming you've set focus to the edit control (by calling SetFocus() ), you should be able to select an empty portion of the text (starting at the location of interest) using SetSel() . So, to position the cursor at the 3rd char, try:
CEdit* pEdit = (CEdit *) GetDlgItem (IDC_EDIT);
ASSERT (pEdit != NULL);
pEdit->SetFocus();
pEdit->SetSel (2, 2, TRUE);
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Alright in my MDI ap I have CFormViews. I know how to set the child frame initialy to fit the form. What I would like to do is keep it that way.
So what would be the easiest way to prevent the child frame that wraps the form from being resizeable by the user?
I have seen some solutions that invlove removing the client edge but I want it to stay looking the way it does (like a regular window).
Thx,
Richard
|
|
|
|
|
You can override the function for WM_NCHITTEST. Call the default implementation and then if it returns one of the borders, then return HTBORDER.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
You can have it the other way around (resize the parent to fit the child view) with CScrollView::ResizeParentToFit . As for having your frame window unresizable, add this PreCreateWindow handler:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style&=~WS_SIZEBOX&~WS_MAXIMIZEBOX;
return CFrameWnd::PreCreateWindow(cs);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That did it! Perfect thanks again!
Thx,
Richard
|
|
|
|
|
Bah, that was TOO easy. Programming shouldn't be that easy!!!!
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I think fixing the size in the WM_GETMINMAXINFO message handler is the easiest way.
Michael
|
|
|
|
|
How to make spin control work with double or float data types?
|
|
|
|
|
This is fairly easy to do. Do the following steps:
1: Set the range of value: If you want a step of 0.1 and a min equal to 0.0 and a max equal to 10.0, the range of value of your spin control must be 0-100 (100 = 10/0.1)
2: Add a message handler for WM_VSCROLL
void CDialog::OnVScroll ( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if (nSBCode == SB_ENDSCROLL)
return ;
if (pScrollBar->GetDlgCtrlID() === IDC_SPIN)
{
CString strValue ;
strValue.Format("%3.1f", (double)(nPos / 10.0)) ;
((CSpinButtonCtrl*)pScrollBar)->GetBuddy()->SetWindowText(strValue) ;
}
}
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
In my application i have a debug error message that occurs when i want to delete a pointer.
in the code:
int *pTabBinPort=new int[m_dlgAsset];
.
.
.
.
delete []pTabBinPort;
i do that at the end of a function, and when i do debug test when it arrives to this point a message error box arrives and i could read this message:
Debug error!
Program : D:\CalcRiskPort\Debug\CalcRiskPort.exe
DAMAGE : before Normal block(#74) at 0x00301E20
So, is anybody could explain to me what is the problem?
Thanks in advance for your answers
gerald
|
|
|
|
|
The error means memory got corrupted for some reason. First thing I'd check is whether you're not running out of bounds when writing to pTabBinPort .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
i don't know if it could help you but i post the entire code of my function:
void CCalcRiskPortDlg::OnCalcvar()
{
UpdateData(TRUE);
::CoInitialize(NULL);
//LoadTables Table;
//LoadTables Table2(m_dlgSector);
double *pTabVar=new double[pow(2,m_dlgAsset)];
CString strValue;
int *pTabBinPort=new int[m_dlgAsset];
int *pTabNumPort=new int[m_dlgAsset];
int k,i;
try
{
LoadTables Table(1,m_dlgSector,1,m_dlgSector);
_ConnectionPtr pConnection=NULL;
CString strTemp;
strTemp.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\CalcRiskPort\\vol_correl1.mdb;");
_bstr_t strCnn(strTemp);
TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
pConnection->Open(strCnn,"","",adConnectUnspecified);
Table.pCorrel=Table.LoadCorrelation(m_dlgSector,Table.pCorrel,"Correlation");
Table.pVol=Table.LoadVolatility(m_dlgSector,Table.pVol,"Volatilité");
i=0;
for(k=0;k<=m_dlgAsset-1;k++)
{
*(pTabBinPort+k)=0;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
}
*pTabVar=Table.CalcVar(pTabNumPort,m_dlgAsset);
for(i=1;i<=pow(2,m_dlgAsset);i++)
{
k=m_dlgAsset-1;
while(*(pTabBinPort+k)==1)
{
*(pTabBinPort+k)=0;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
k--;
}
*(pTabBinPort+k)=1;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
*(pTabVar+i)=Table.CalcVar(pTabNumPort,m_dlgAsset);
}
pConnection->Close();
}
catch(_com_error &e)
{
AfxMessageBox("a pas bon");
}
m_dlgValue=pTabVar[2];
strValue.Format("%.9f",m_dlgValue);
CEdit* PEdit=(CEdit*)GetDlgItem(IDC_VALUE);
PEdit->SetWindowText(strValue);
delete []pTabBinPort;
delete []pTabNumPort;
delete []pTabVar;
::CoUninitialize();
// TODO: Add your control notification handler code here
}
i hope it help you
regards
|
|
|
|
|
It's hard to say... This is a little suspicious:
for(i=1;i<=pow(2,m_dlgAsset);i++)
{
...
*(pTabVar+i)=Table.CalcVar(pTabNumPort,m_dlgAsset);
} i runs between 1 and 2m_dlgAsset , and then you use it as an index to <cpde>pTabVar. I think you should change the last sentence to
*(pTabVar+i-1)=...;
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
This looks suspicious as well:
while(*(pTabBinPort+k)==1)
{
*(pTabBinPort+k)=0;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
k--;
} Could there be any chance that k is <0 and you step out of bounds?
Putting an assert on k after decrement or (better yet?) VERIFY(--k >= 0) should help detect this problem in debug mode.
|
|
|
|
|
i've just read your post and i think that it's exactly the problem, because, when i arrive to pTabBinPort[0], i decrement again k so that it will be equal to -1. So, i will test it to see if it works;
thanks a lot
|
|
|
|
|
in fact in my code i change 2 things:
for(i=1;i<=pow(2,m_dlgAsset)-1;i++)
{
k=m_dlgAsset-1;
while(*(pTabBinPort+k)==1)
{
*(pTabBinPort+k)=0;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
if(k!=0)
k--;
}
*(pTabBinPort+k)=1;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
*(pTabVar+i)=Table.CalcVar(pTabNumPort,m_dlgAsset);
}
you could see in the for statement that i going from 1 to pow(2,m_dlgAsset)-1 now and i've put a test in the while loop just for the case of k=0, so that we couldn't be in the situation of k=-1.
But now i have another problem, when i test my application with m_dlgSector=30 and m_dlgAsset=15, at the end of the function i have another message error which says:
Unhandled exception in CalcRiskport.exe (MFC42.DLL):0xC0000005:Access Violation. It's happened at this line:
strValue.Format("%.5f",m_dlgValue);
You could see the whole code in the precedent post.
|
|
|
|
|
You are not changing pTabBinPort anywhere are you? If you want to do some pointer arithmetic do it on a tmp pointer variable.
Or it could be that you are overflowing the allocated memory
Nish
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|
|
I have a problem when I start to monitor the serial port for a BREAK signal.
It seems that a situation occur when there are BREAK signals on "the queue". That is that if I trigger a BREAK signal just before I monitor the UART port this BREAK signal can triggers the program when I start to monitor the UART.
There must be a way to clear the BREAK signal queue before I start to monitor the UART... How do I do that??
There is somethin called PURGE UART but this seem only to clear the TX and RX line, not the BREAK signal line.
Please help!!
|
|
|
|
|
ClearCommError
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
ehhh sorry about that. Do I feel lucky...well should I!?
I hope so, cause I would be very VERY grateful if you let me know the answer to my problem.
|
|
|
|
|
I am developing an MDI app. In this app I have two documents and one view for each document. Doc1 is persistant so there is only one instance of it period and that gets opened on startup by default. Doc2's view needs to be able to access a variable in Doc1. I can get a pointer to Doc1 in Doc2's view like so:
Doc2view.h
public:
CDoc2* GetDocument();
CDoc1* GetDBDocument();
....
#ifndef _DEBUG
inline CDoc2* CDoc2view::GetDocument()
{ return (CDoc2*)m_pDocument; }
#endif
#ifndef _DEBUG
inline CDoc1* CDoc2view::GetDBDocument()
{ return (CDoc1*)m_pDocument; }
#endif
Now in Doc2's view I can access the pointer to Doc1 of cource like:
CString Value;
CDoc1* pDoc = GetDBDocument();
Value = pDoc->StoredValue;
The problem is that does not point to the current instance of Doc1 for some reason. When I try and access the variable in Doc1 it returns nothing. In the above example Value would return nada.
Please help I am a little new to MDI programming so this is confusing me.
Thx,
Richard
|
|
|
|