|
Why not redirect the standard output (stdout) streaming in a file (output.txt)...
For that, add a Program argument:
=> in your projects setting (in release mode)
=> tab "Debug"
=> category "general"
=> and Program argument = ">output.txt 2>&1"
Now you can use printf("All what you want\n") for debugging your app and the output.txt file catch your stream...
Hello World!!!
from Raphaël
|
|
|
|
|
|
Create new configuration based on Release, but enable debug info generation on C++ and Link tabs of Settings dialog. Execute the program under debugger, try to reproduce error and check the call stack when program crashes.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Hi!!
I've created a dialog based application (Multithreaded)in VC++ 7.0. I've only used MFC thread and CFile clases in this application. After linking this application in Release mode, the size of exe found to be 210 KB.
Is there any way we can reduce the size of MFC apps.???
|
|
|
|
|
http://www.microsoft.com/msj/defaulttop.asp?page=/msj/archive/S572.htm
contains good info though
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I have an Access database for students
and want to get record on paper for one student redirected (sent) to
MS Word
can anybody suggest how to do this
|
|
|
|
|
CComvariant var;
CCombstr bstr;
How to convert this var to c-style string safely.Any macro is there.Pl also tell me for converting from bstr to c-style string.
|
|
|
|
|
Actually Mike and Nish have wrote an article which "probably" answers that very question...
Index page...check it out...
http://www.codeproject.com/string/CPPStringGuide2.asp[^]
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
There are some ATL conversion macros declared in ATLCONV.h.
You will need to declare USES_CONVERSION; in the function that will be using the conversion macros. THis macro declares a few variables on the stack.
Then you can use OLE2T(bstr) to convert your bstr to your C-Style string. There are a slew of macros to convert from (A)Ansi to (W)widechar, to (bstr)bstr including (c)constants and whatever else. The convention is to use the format that you are going from like (A)ansi then a 2 followed by the format converting to like a (BSTR)bstr. Your final macro would be A2BSTR().
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi!
I am creating a dialog with the Create member function.
So, I would like to change the window styles (like WS_CAPTION, WS_CHILD, ... ) before or after creating the dialog!
I want to do like something:
CMyDlg dlg;
dlg.???(...);
dlg.Create(CMyDlg::IDD);
dlg.???(...);
dlg.ShowWindow(SW_SHOW);
How can I change the window styles, before or after creating the dialog and display it on the screen?
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Daniel S. wrote:
How can I change the window styles, before or after creating the dialog and display it on the screen?
I don't think you can change the dialog windows styles before creating it...but you could do it during creation using CreateIndirect() or after using SetClassLong() with GCL_STYLE as a parameter. If my memory serves me correctly and you like doing things the hard way (like me somtimes) you could prolly initialize a WNDCLASS with all the desired WS_??? styles and the call CreateWindowEx() and them somehow the following...
MSDN:
The CreateDialog function uses the CreateWindowEx function to create the dialog box. CreateDialog then sends a WM_INITDIALOG message (and a WM_SETFONT message if the template specifies the DS_SETFONT style) to the dialog box procedure. The function displays the dialog box if the template specifies the WS_VISIBLE style. Finally, CreateDialog returns the window handle to the dialog box.
Just some suggestions...
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Use the ModifyStyle and ModifyStyleex member functions.
The first parameter is the styles that you would like to remove from the window, the second parameter is the style that you would like to add, and the third parameter is related to if you changed a style that affects the borders of the window.
Look in MSDN for more details.
Good Luck.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
In my experience, some things don't work with ModifyStyle and ModifyStyleEx.
For example, making the title bar like a toolbar works whereas completely removing it doesn't. The bizzare thing is that for the latter, the window behaves (when you click on it with a mouse) as though the title bar does not exist even when it is still visible (in W2k anyway?!)
it drove me nuts!
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
<code>
include "stdafx.h"
#include <iostream.h>
#include <windows.h>
#include <tchar.h>
#define ErrorHandler(s) _ErrorHandler(s, __FILE__, __LINE__)
void _ErrorHandler(LPCSTR lpszLocation, LPCTSTR lpszSrcFile, UINT nSrcLine)
{
LPVOID lpMsgBuf;
DWORD dwError = GetLastError();
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPSTR) &lpMsgBuf,
0,
NULL );
// Process any inserts in lpMsgBuf.
cout<<"ERROR @ "<<lpszLocation<<" : "<<'('<<dwError<<')'<<(LPCSTR)lpMsgBuf;
cout<<"SOURCE @ Line = "<<nSrcLine<<", File = "<<lpszSrcFile<<'\n';
// Free the buffer.
LocalFree( lpMsgBuf );
}
BOOL SetFileOwner(LPCTSTR lpszFileName, LPCSTR lpszAccount, LPCSTR lpszGroup)
{
PSECURITY_DESCRIPTOR pSD;
PSID pSID, pSIDGroup;
DWORD cbSID = 1024;
LPSTR lpszDomain;
DWORD cchDomainName = 80;
PSID_NAME_USE psnuType;
// Initialize a security descriptor.
pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR,
SECURITY_DESCRIPTOR_MIN_LENGTH); // defined in WINNT.H
if (pSD == NULL) {
ErrorHandler("LocalAlloc");
goto Cleanup;
}
if (!InitializeSecurityDescriptor(pSD,
SECURITY_DESCRIPTOR_REVISION)) { // defined in WINNT.H
ErrorHandler("InitializeSecurityDescriptor");
goto Cleanup;
}
// Retrieve the SID for User.
pSID = (PSID) LocalAlloc(LPTR, cbSID);
psnuType = (PSID_NAME_USE) LocalAlloc(LPTR, 1024);
lpszDomain = (LPSTR) LocalAlloc(LPTR, cchDomainName);
if (pSID == NULL || psnuType == NULL ||
lpszDomain == NULL) {
ErrorHandler("LocalAlloc");
goto Cleanup;
}
if (!LookupAccountName((LPSTR) NULL, // local name
lpszAccount,
pSID,
&cbSID,
lpszDomain,
&cchDomainName,
psnuType)) {
ErrorHandler("LookupAccountName");
goto Cleanup;
}
if (!IsValidSid(pSID))
{
ErrorHandler("IsValidSid");
goto Cleanup;
}
// Sets the owner to the SD
if (!SetSecurityDescriptorOwner(pSD, pSID, FALSE)) { // not a default SID
ErrorHandler("SetSecurityDescriptorOwner");
goto Cleanup;
}
// Retrieve the SID for Group.
cbSID = 1024;
pSIDGroup = (PSID) LocalAlloc(LPTR, cbSID);
if (pSIDGroup == NULL) {
ErrorHandler("LocalAlloc");
goto Cleanup;
}
if (!LookupAccountName((LPSTR) NULL, // local name
lpszGroup,
pSIDGroup,
&cbSID,
lpszDomain,
&cchDomainName,
psnuType)) {
pSIDGroup = (PSID)LocalReAlloc((HLOCAL) pSIDGroup, cbSID, LPTR);
lpszDomain = (LPSTR) LocalReAlloc((HLOCAL) lpszDomain, cchDomainName, LPTR);
if (pSIDGroup == NULL || lpszDomain == NULL) {
ErrorHandler("LocalReAlloc");
goto Cleanup;
}
if (!LookupAccountName((LPSTR) NULL, // local name
lpszGroup,
pSIDGroup,
&cbSID,
lpszDomain,
&cchDomainName,
psnuType)) {
ErrorHandler("LookupAccountName");
goto Cleanup;
}
}
if (!IsValidSid(pSIDGroup))
{
ErrorHandler("IsValidSid");
goto Cleanup;
}
// Sets the group to the SD
if (!SetSecurityDescriptorGroup(pSD, pSIDGroup, FALSE)) { // not a default SID
ErrorHandler("SetSecurityDescriptorGroup");
goto Cleanup;
}
// Use the new SD as the file's security info.
if (!SetFileSecurity(lpszFileName, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION, pSD)) {
ErrorHandler("SetFileSecurity");
goto Cleanup;
}
return TRUE;
Cleanup:
FreeSid(pSID);
FreeSid(pSIDGroup);
if(pSD != NULL)
LocalFree((HLOCAL) pSD);
if(psnuType != NULL)
LocalFree((HLOCAL) psnuType);
if(lpszDomain != NULL)
LocalFree((HLOCAL) lpszDomain);
return FALSE;
}
int _tmain(int argc, TCHAR *argv[], TCHAR *envp[])
{
if (argc < 4) {
cout<<"ERROR @ main : Not enough parameters\n";
return 0;
}
TCHAR tszFileName[MAX_PATH];
char szUserName[256];
char szGroupName[256];
_tcscpy(tszFileName, argv[1]);
#if defined(_UNICODE) || defined(UNICODE)
if (!WideCharToMultiByte(CP_ACP, 0, argv[2], -1, szUserName, 256, NULL, NULL)) {
ErrorHandler("WideCharToMultiByte");
return 0;
}
if (!WideCharToMultiByte(CP_ACP, 0, argv[3], -1, szGroupName, 256, NULL, NULL)) {
ErrorHandler("WideCharToMultiByte");
return 0;
}
#else
strcpy(szUserName, argv[2]);
strcpy(szGroupName, argv[3]);
#endif
if (!SetFileOwner(tszFileName, szUserName, szGroupName)) {
cout<<"Operation Failed!\n";
return 0;
}
cout<<"Operation Succeeded!\n";
return 0;
}
</code>
=======================================================================
This program can set file and dir owner for "administrator"
or "administrators", but can't set for other user, else return
the "ERROR_INVALID_OWNER(1703L)"...
Why??? Please help me ~!!!
=======================================================================
|
|
|
|
|
|
Hello,
I would like to use DrawText on top of my application window. The window itself contains a child window. How do I use DrawText on top of both window? I can draw it directly to the screen DC but it's hard to prevent drawing to other windows not belong to my window when my application is partially covered by other application. I also tried to SetWindowLong(m_hParent, GWL_STYLE, GetWindowLong(GWL_STYLE) & ~WS_CLIPCHILDREN); but the text still covered by the child window. Do you have solution for this problem?
Thanks,
Hiusing
|
|
|
|
|
Why not just use the childs DC...??
Obviously i am misunderstanding something...you want to draw overtop of both windows child and parent but also want to make whatever the parent contains visible through the child also...?
MSDN:
If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window.
WS_CLIPSIBLINGS won't do what you desire I don't think
Perhaps create the child window with a NULL brush, this way everything underneath remains visible...
MSDN:
CS_PARENTDC Sets the clipping region of the child window to that of the parent window so that the child can draw on the parent. A window with the CS_PARENTDC style bit receives a regular device context from the system's cache of device contexts. It does not give the child the parent's device context or device context settings. Specifying CS_PARENTDC enhances an application's performance. For more information, seeDevice Contexts.
This might give you the desired effect also so long as your child window returns FALSE in OnEraseBkgnd()
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hello,
I am trying to create a UI thread and use CSocket with in the thread to do a file transfer. I have created my own CWinThread class and a CSocket Class..
I keep getting a error when I try to create the socket inside of the thread.
Here is the error, in debug mode..
void* CMapPtrToPtr::GetValueAt(void* key) const
{
if (m_pHashTable == NULL)<-- HERE
return NULL;
UINT nHash = HashKey(key) % m_nHashTableSize;
CAssoc* pAssoc;
for (pAssoc = m_pHashTable[nHash]; pAssoc != NULL; pAssoc = pAssoc->pNext)
{
if (pAssoc->key == key)
return pAssoc->value;
}
return NULL;
}
In my InitInstance() inside the thread i do a..
BOOL CFtThread::InitInstance()
{
if(!AfxSocketInit())
return FALSE;
return TRUE;
}
and in my "int CFtThread::Run()" I try to Create the socket, thats when I get the error..
Here is how I am trying to create the thread in my main app.. maybe this has something to do with it..
CFtThread* pThread = (CFtThread*)AfxBeginThread(RUNTIME_CLASS(CFtThread),
THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
pThread->m_strAddress = pView->m_strClientDns;
pThread->m_nPort = 21;
pThread->m_strFile = strFilePath;
pThread->m_bAutoDelete = TRUE;
pThread->ResumeThread();
I have seen posts at articles on CodeProject that say that the AfxSocketInit() fixed their problems but I am still having the problem...
Thanks in advance!!
|
|
|
|
|
I just found the answer to my question on microsofts site.. so if anyone else sees this problem heres the work around..
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q193101
Rob
|
|
|
|
|
hi evryone,
i m a beginer VC++ prog.
i have to make a prjct in VC++ for my college project whch will allow access to all desktops in a LAN.
i want to know abt the features reqd to implemnet it and any reference help if avlble.
THNX for any help
|
|
|
|
|
I have a code statements using STL and CString of MFC:
#include <vector>
#include <afx.h>
vector<CString> strs;
vector<CString>::iterator pos;
pos = find(m_lstPy.begin() + nIndexStart, m_lstPy.end(), lpszFind); // Error line
....
The building error:
error C2440: '=' : cannot convert from 'const class CString *' to 'class CString *' Conversion loses qualifiers
|
|
|
|
|
try this:
CString temp = lpszFind;
pos = find(m_lstPy.begin() + nIndexStart, m_lstPy.end(), temp);
or
pos = find(m_lstPy.begin() + nIndexStart, m_lstPy.end(), &temp);
-c
Green's Law of Debate:
Anything is possible if you don't know what you're talking about.
|
|
|
|
|
the problem is exist yet!!
Please test your code befer place it here!!!
|
|
|
|
|
IMiracle wrote:
Please test your code befer place it here!!!
yes i did. here is the entire program that i used to test it:
#include "stdafx.h"
#include "mfcmfmcc.h"
#include <vector>
#include <algorithm>
#include <afx.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
vector<CString> strs;
vector<CString>::iterator pos;
const char * lpszFind = "hi";
pos = find(strs.begin(), strs.end(), lpszFind);
}
return nRetCode;
}
the problem is apparently not in the code you're showing us.
-c
Green's Law of Debate:
Anything is possible if you don't know what you're talking about.
|
|
|
|
|
Thank you!
What is about mfcmfmcc.h and mfcmfmcc.cpp
|
|
|
|
|