|
What's the question?
If you want to share this calculator, then write a tip or an article:
Code Project Article FAQ[^]
In some cases, my signature will be longer than my message...
<em style="color:red"> <b>ProgramFOX</b></em> ProgramFOX
|
|
|
|
|
what's your question ?
warning ?
|
|
|
|
|
Hi all,
on higher resolution or large DPI the dialog box of my application is not fully visible.
i want to add the auto scroll option for higer resolution in my dialog box,so the dialog is accessible and fully visible.
pleae help me how can i do this thanks in advance.
|
|
|
|
|
Modify your dialog! You really need to provide some proper information if you expect a sensible response to this question. However, if you have a dialog that is too big for the screen you may need to rethink what you are using it for.
|
|
|
|
|
the dialog is not too big and its display normal and properly for normal screen resolution and DPI.
|
|
|
|
|
Check here, I hope to use.
modified 18-Feb-13 2:39am.
|
|
|
|
|
I need to send a client certificate with a web request (via SSL). This client cert is just a public key. I am trying to replicate the Request.ClientCertificates.Add(Cert); .NET method using C++/WinHTTP. I am loading the .cer file successfully and setting the CERT_CONTEXT via WinHttpSetOption/WINHTTP_OPTION_CLIENT_CERT_CONTEXT. This call succeeds, but when I call WinHttpSendRequest, it fails with ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY (12185).
So, the question is, how do I send a client cert public key to the server, as the ClientCertificates.Add method does in .NET? Code snippet sample below:
BOOL HTTPCallEx::SendHTTPRequest(int iVerb , LPCTSTR cpUID , LPCTSTR cpPWD )
{
WCHAR wcaVerb[16];
WCHAR wcaResource[1024];
m_dwLastError = 0;
switch (iVerb)
{
case HTTPCALL_POST:
lstrcpyW(wcaVerb,L"POST");
break;
case HTTPCALL_HEAD:
lstrcpyW(wcaVerb,L"HEAD");
break;
case HTTPCALL_PUT:
lstrcpyW(wcaVerb,L"PUT");
break;
case HTTPCALL_DELETE:
lstrcpyW(wcaVerb,L"DELETE");
break;
case HTTPCALL_OPTIONS:
lstrcpyW(wcaVerb,L"OPTIONS");
break;
case HTTPCALL_TRACE:
lstrcpyW(wcaVerb,L"TRACE");
break;
case HTTPCALL_CONNECT:
lstrcpyW(wcaVerb,L"CONNECT");
break;
case HTTPCALL_GET:
default:
lstrcpyW(wcaVerb,L"GET");
break;
}
#ifdef UNICODE
_tcscpy(wcaResource,m_caResource);
#else
MultiByteToWideChar(CP_UTF8,0,m_caResource,-1,wcaResource,1024);
#endif
m_hRequest = WinHttpOpenRequest(m_hConnect,wcaVerb,wcaResource,NULL,WINHTTP_NO_REFERER,WINHTTP_DEFAULT_ACCEPT_TYPES,(m_bSSL ? WINHTTP_FLAG_SECURE : 0));
if (!m_hRequest)
{
m_dwLastError = ::GetLastError();
return FALSE;
}
if (cpUID && *cpUID)
{
WCHAR wcaUID[512];
WCHAR wcaPWD[512];
#ifdef UNICODE
_tcscpy(wcaUID,cpUID);
#else
MultiByteToWideChar(CP_UTF8,0,cpUID,-1,wcaUID,512);
#endif
if (cpPWD && *cpPWD)
#ifdef UNICODE
_tcscpy(wcaPWD,cpPWD);
#else
MultiByteToWideChar(CP_UTF8,0,cpPWD,-1,wcaPWD,512);
#endif
else
wcaPWD[0] = 0;
if (!WinHttpSetCredentials(m_hRequest,
WINHTTP_AUTH_TARGET_SERVER,
WINHTTP_AUTH_SCHEME_BASIC,
wcaUID,
wcaPWD,
NULL))
{
m_dwLastError = ::GetLastError();
return FALSE;
}
}
if (m_dwRequestTimeout)
{
if (!WinHttpSetOption(m_hRequest,WINHTTP_OPTION_RECEIVE_TIMEOUT,&m_dwRequestTimeout,sizeof(m_dwRequestTimeout)))
{
m_dwLastError = ::GetLastError();
return FALSE;
}
}
if (m_pCertCtxt)
{
DWORD dwFlags = SECURITY_FLAG_IGNORE_CERT_CN_INVALID |
SECURITY_FLAG_IGNORE_CERT_DATE_INVALID |
SECURITY_FLAG_IGNORE_UNKNOWN_CA |
SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE;
WinHttpSetOption(m_hRequest,WINHTTP_OPTION_SECURITY_FLAGS,&dwFlags,sizeof(dwFlags));
if (!WinHttpSetOption(m_hRequest,WINHTTP_OPTION_CLIENT_CERT_CONTEXT,(void *)m_pCertCtxt,sizeof(CERT_CONTEXT)))
{
if (m_pCertCtxt)
m_dwLastError = ::GetLastError();
else
m_dwLastError = 50000;
return FALSE;
}
}
if (m_oCustomHeaders.GetSize() > 0)
{
CString cHeader;
WCHAR wcaHeaderBuf[2048];
for (int iLup = 0; iLup < m_oCustomHeaders.GetSize(); iLup++)
{
cHeader = m_oCustomHeaders.GetAt(iLup);
#ifdef UNICODE
_tcscpy(wcaHeaderBuf,(LPCTSTR)cHeader);
#else
MultiByteToWideChar(CP_UTF8,0,(LPCSTR)cHeader,-1,wcaHeaderBuf,2048);
#endif
WinHttpAddRequestHeaders(m_hRequest,wcaHeaderBuf,lstrlenW(wcaHeaderBuf),WINHTTP_ADDREQ_FLAG_ADD);
}
}
DWORD dwContentLength = 0;
if ((iVerb == HTTPCALL_POST || iVerb == HTTPCALL_PUT) && m_cpPostData)
{
if (m_iPostDataLen < 0)
dwContentLength = (DWORD)strlen(m_cpPostData);
else
dwContentLength = (DWORD)m_iPostDataLen;
}
if (!WinHttpSendRequest(m_hRequest,WINHTTP_NO_ADDITIONAL_HEADERS,NULL,(LPVOID)(m_cpPostData ? m_cpPostData : ""),dwContentLength,dwContentLength,0))
{
>>>>> THIS FAILS HERE WITH ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY (12185)
m_dwLastError = ::GetLastError();
return FALSE;
}
if (!WinHttpReceiveResponse(m_hRequest,NULL))
{
m_dwLastError = ::GetLastError();
return FALSE;
}
TCHAR caBuf[81];
caBuf[0] = 0;
int iBufSize = sizeof(caBuf)/sizeof(TCHAR);
if (!GetStandardHeader(WINHTTP_QUERY_STATUS_CODE,caBuf,&iBufSize))
{
m_dwLastError = ::GetLastError();
return FALSE;
}
m_dwHTTPStatus = _ttol(caBuf);
caBuf[0] = 0;
iBufSize = sizeof(caBuf)/sizeof(TCHAR);
if (!GetStandardHeader(WINHTTP_QUERY_CONTENT_LENGTH,caBuf,&iBufSize)) m_dwContentLength = 0;
else
m_dwContentLength = _ttol(caBuf);
return TRUE;
}
As usual, this is on a deadline, so any help is greatly appreciated! Certificate loading is shown below:
BOOL LoadCertificate(ApplicationInstance *pAppInst)
{
BOOL bRetval = FALSE;
int iThreadCount = (int)pAppInst->m_pLightningServer->m_wNumWorkerThreads;
TCHAR caCertFilePath[256];
caCertFilePath[0] = 0;
if (!pAppInst->GetUserTagValue(_T("CertFilePath"),caCertFilePath,sizeof(caCertFilePath)/sizeof(TCHAR)))
_tcscpy(caCertFilePath,_T("c:\\webapps\\test.cer"));
theApp.m_hStore = CertOpenStore(CERT_STORE_PROV_FILENAME,
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
NULL,
CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY_FLAG,
caCertFilePath);
if (theApp.m_hStore)
{
PCCERT_CONTEXT *pCertList = new (PCCERT_CONTEXT[iThreadCount]);
if (pCertList)
{
for (int iCert = 0; iCert < iThreadCount; iCert++)
pCertList[iCert] = NULL;
pAppInst->SetUserPtr((void *)pCertList);
PCCERT_CONTEXT pCertCtxt = CertFindCertificateInStore(theApp.m_hStore,
X509_ASN_ENCODING,
0,
CERT_FIND_SUBJECT_STR,
(LPVOID)_T("test.myserver.com"), NULL );
if (pCertCtxt)
{
pCertList[0] = pCertCtxt;
for (int iLup = 1; iLup < iThreadCount; iLup++)
pCertList[iLup] = CertDuplicateCertificateContext(pCertCtxt);
bRetval = TRUE;
}
else
{
pAppInst->m_pLightningServer->WriteErrorLog(-3,_T("APPINIT: Error Getting CERT_CONTEXT From Store"),caCertFilePath,NULL,FALSE);
}
}
else
{
pAppInst->m_pLightningServer->WriteErrorLog(-2,_T("APPINIT: Error MemAlloc CERT_CONTEXT Array"),NULL,NULL,FALSE);
}
}
else
{
DWORD dwError = GetLastError();
TCHAR caErrBuf[1024];
_stprintf(caErrBuf,_T("APPINIT: Error Opening Cert Store [%d]..."),dwError);
::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
caErrBuf+_tcslen(caErrBuf),
sizeof(caErrBuf)/sizeof(TCHAR)-40,
NULL);
pAppInst->m_pLightningServer->WriteErrorLog(-1,caErrBuf,caCertFilePath,NULL,FALSE);
}
return bRetval;
}
onwards and upwards...
|
|
|
|
|
) If two dice are rolled. what is the probability of getting (1, 2), or (2, 3) and so on. We can answer
these questions analytically, but you need to write a code to verify the results. You can do that
following the steps:
a. Write a function rollDices that takes two parameters as output parameters (return values through
them). The function when called should return two random integers, each one between 1 and 6,
where each one represent the value of a rolled die.
Use the following code to generate a random number between a and b. We seed the random
number generator using srand function as shown below.#include <time.h>
#include <stdlib.h>
using namespace std;
//... you other functions ...
int main () {
// seed random number generator
srand ( time(NULL) );
// your other code here
// generate a random number between 1 and 10
int randomNumber = rand() % 10 + 1;
}
b. Write another function rollProb that takes a two dimensional array 6x6 and an integer
numberOfRolls. The function should call the rollDices function numberOfRolls times, and for
each call it should increment the corresponding cell in the array.
c. Your main program should prompt the user for the numberOfRolls and calls the function rollProb
and then prints the probability of obtaining each pair of values. Try it with 4 different number of
rolls: 100, 1000, 10000, 100000. I will explain it more in class.
|
|
|
|
|
Is it urgentz?
Really though, please see here[^] especially point #11.
|
|
|
|
|
Haiathem alhmoud wrote: ) If two dice are rolled. what is the probability of getting (1, 2), or (2, 3) and so on. 1/6 * 1/6
Haiathem alhmoud wrote: I will explain it more in class. So, what happened?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I am trying to find a list of ‘affected’ API in Windows 8.
Microsoft used to release a file called Win32Api.Csv that would summarize every function call changed in a new version of the OS.
I am looking for something similar for Windows 8.
I don't necessarily need the 'new functions' list, I have seen that already.
I am concerned we make function calls in our existing products that will be 'broken' in some manner in Windows 8. For example, we have already run into some
FindWindow failures.
Sigh.... so many Windows OS versions, so little time …
|
|
|
|
|
Maybe you should look on Microsoft's Windows 8 web pages.
|
|
|
|
|
I'm working with a code that I found online. After I resolved all the errors I tried to run the program, but it keeps giving me an unhandled exception.
1>httpsink.obj : error LNK2001: unresolved external symbol _IID_IXMLHTTPRequest
1>httpsink.obj : error LNK2001: unresolved external symbol _CLSID_XMLHTTP30
1>uafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___wargv
1>uafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
1>MSVCRT.lib(crtexew.obj) : error LNK2001: unresolved external symbol _WinMain@16
1>C:\Users\ABC\Documents\Visual Studio 2008\Projects\httpsink\Release\httpsink.exe : fatal error LNK1120: 5 unresolved externals
Any help is welcome.
|
|
|
|
|
Those are not exceptions, they are linker messages, telling you that you have some missing library references. The first two are references to the MSXML[^] library. If you do not have it installed then you need to download it using the foregoing link. The remaining three suggest that you don't have a WinMain() [^] function in your code. However, it may well be that the code is incomplete, and you should check with the person who wrote it.
|
|
|
|
|
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I don't understand how to programming in MCF CPP, I would like to
build my own DB such as excel and word documents.
|
|
|
|
|
|
FranksLIC wrote: I don't understand how to programming in MCF CPP
I would start by googling "MFC Hello World", then locate a good book about MFC programming like this[^] one for example.
|
|
|
|
|
FranksLIC wrote: I would like to
build my own DB such as excel and word documents.
I do not want to burst your bubble, but you should give yourself a more modest initial goal.
Wanting to build your own DB, Excel or Word is too big a project even for advanced/expert programmers; those are quite complex softwares.
Start by learning the basics; there are TONS of samples and examples either here on CodeProject or even the MFC samples on MSDN are a good start (to learn the MFC framework).
Good luck.
Nihil obstat
|
|
|
|
|
Hope you mean MFC. I think first yo should understand what is MFC. Because it is wast library that wraps portions of the Windows API in C++ classes. When studying we must start from it's basic. If we got a good basic knowledge then we can develop anything through a programming language. So stduy well, understand well.
All the best.
|
|
|
|
|
As the title says I am trying to host a .net modeless form inside an MFC dialog. I read the article Using WinForms controls in an MFC dialog[^] but I do not want to do it this was because I do not wish to compile the project that contains the MFC dialog in /clr.
So I tried a different path.
I created a /clr dll that exports a very simple function
HWND getDotNetWindowHandler()
{
HostedForm ^frm = gcnew HostedForm();
return static_cast<HWND>(frm->Handle.ToPointer());
}
The hosted form is a .net form without borders. So my dialog takes the handler(by calling the dll, no need to show the implementation here) and places the form in a STATIC control window.
m_pDotNetWnd = CWnd::FromHandle(getDotNetWindowHandler());
CWnd* pWndContainer = GetDlgItem(IDC_DOTNET_WND);
if(m_pDotNetWnd != NULL && pWndContainer != NULL)
{
m_pDotNetWnd->SetParent(pWndContainer);
m_pDotNetWnd->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_ASYNCWINDOWPOS | SWP_FRAMECHANGED);
m_pDotNetWnd->ShowWindow(SW_SHOW);
HWND hWndChild = m_pDotNetWnd->GetSafeHwnd();
// reset the style
DWORD style = GetWindowLong(hWndChild, GWL_STYLE);
style &= ~(WS_POPUP|WS_CAPTION); //reset the "caption" and "popup" bits
style |= WS_CHILD; //set the "child" bit
SetWindowLongPtr(hWndChild, GWL_STYLE, style); //set the new style
}
Everything seems to work just fine but after a while I am having a deadlock. The window freezes.
After a lot of research on the internet it seems to be a problem with the SendMessage when the child window is created from a different thread. I couldn't find any workarround though. Is there any? Can someone give me a clue?
|
|
|
|
|
Hello Everybody,
I am new to MFC. I used the application wizard to create a SDI application, I was able to replace the existing menu and toolbar.
In this, I added a dialog with some controls. Now, what I need is, whatever the details I got from the dialog controls, I need to display the document view.
On CView::OnDraw,I added the code like this.
<code>
CSDITestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
pDC->TextOut(20, 20, L"test sdi", 10);
</code>
This text is writing only once in the beginning. On closing the dialog, this function is not called, how can I do that?
I tried with UpdateAllViews and OnUpdate also.
Thanks in advance.
A. Gopinath.
|
|
|
|
|
On CView::OnDraw,I added the code like this
Really?
|
|
|
|
|
Ok, I understood what you are trying to say.
I added this line only in the existing function.
pDC->TextOut(20, 20, L"test sdi", 10);
Also, I would request you to read the "How to answer the question", especially, 3rd point.
|
|
|
|
|
You need to show some more of your code, as it is not obvious where these different events occur. Pleas also use <pre> tags around your codeblocks so they are readable, like this:
CSDITestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
pDC->TextOut(20, 20, L"test sdi", 10);
|
|
|
|
|