string s(" how are you"); remove_if(s.begin(), s.end(), isspace); cout<<s;
why the output is "howareyouou" instead of "howareyou"?
string s(" how are you"); remove_if(s.begin(), s.end(), isspace); cout<<s;
The GetDiskFreeSpace method returns values for NumberOfFreeClusters and TotalNumberOfClusters based on what is "available to the user who is associated with the calling thread". This limitation means that the values returned are different depending on network quotas, etc..
I need an alternative in C++ to GetDiskFreeSpace that does not have this limitation and that will return the same values (after you do the multiplication) as the Windows Explorer properties dialog does for a mounted drive.
Is there a more accurate alternative to GetDiskFreeSpace in C++?
Hi
I am stuck. please can someone be of help. am learning c++ using these textbook. I was asked as part of an exercise, to organise some programs into their own namespaces and compile the whole program. I have divided these into two. (a) the original programs( not in namespaces ) and (b) how I tried to solve the problem ( with the programs in their own namespaces ) I was getting these error messages. Microsoft visual studio 2015 compiler
1) Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "class chapter_15::Query __cdecl chapter_15::operator|(class chapter_15::Query const &,class chapter_15::Query const &)" (??Uchapter_15@@YA?AVQuery@0@ABV10@0@Z) referenced in function _main namespaces_chapter_18 C:\Users\evan_2\Documents\Visual
Studio 2015\Projects\namespaces_chapter_18\namespaces_chapter_18\namespaces_chapter_18.obj 1
2) Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "class chapter_15::Query __cdecl chapter_15::operator&(class chapter_15::Query const &,class chapter_15::Query const &)" (??Ichapter_15@@YA?AVQuery@0@ABV10@0@Z) referenced in function
_main namespaces_chapter_18 C:\Users\evan_2\Documents\Visual Studio 2015\Projects\namespaces_chapter_18\namespaces_chapter_18\namespaces_chapter_18.obj 1
3) Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: __thiscall chapter_15::Query::Query(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0Query@chapter_15@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main namespaces_chapter_18 C:\Users\evan_2\Documents\Visual Studio 2015\Projects\namespaces_chapter_18\namespaces_chapter_18\namespaces_chapter_18.obj 1
4)Severity Code Description Project File Line Suppression State
Error LNK1120 3 unresolved externals namespaces_chapter_18 C:\Users\evan_2\Documents\Visual Studio 2015\Projects\namespaces_chapter_18\Debug\namespaces_chapter_18.exe 1
I know what LNK2019 means, but I don't know what am doing wrong
here goes the codes
(a) the original codes
textquery.cpp : - broken down into textquery.cpp and textquery.h , in my solution
std::shared_ptr<std::vector<std::string>> QueryResult::get_file() const
{
return file;
}
ostream &print(ostream & os, const QueryResult &qr)
{ // if the word was found, print the count and all occurrences
os << qr.sought << " occurs " << qr.lines->size() << " " << ((qr.lines->size() > 1) ? "times" : "time") << endl;
// print each line in which the word appeared
for (auto num : *qr.lines) // for every element in the set
// don't confound the user with text lines starting at 0
os << "\t(line " << num + 1 << ") " << *(qr.file->begin() + num) << endl;
return os;
}
query_base.cpp : - includes textquery.cpp as textquery.h
b) my solution. contains 5 files.
(I) namespaces_chapter_18.cpp, the main program
(ii) textquery_namespace.h, a header file
#endif // !1
(iii) textquery_namespace.cpp, source file
(iv) query_base_namespace.h, a header file
};
}
#endif // ! QUERY_BASE_NAMESPACE
(v) query_base_namespace.cpp, a source file
thanks for reading up to here. your help will be highly appreciated
Hi, I am trying to use setparent point to the desktop window, is there any samples? I failed in creating in this way
m_bannerTop->SetParent(GetDesktopWindow())
Hi, I checked other resources regarding this, but quite limited. Is there any sample regarding popup dialog resize and move as main dialog resize and move?
Thanks
Hi,
I'm searching for the "Direc3D9Ex and DXGI Interop Helper and Sample" referenced on the MSDN article "Surface Sharing Between Windows Graphics APIs" . All urls related to D3D9ExDXGISharedSurf are redirected to a page telling "The archive gallery has been retired".
Is there anywhere else I could get this sample ?
Thanks
Hi,
I have an MFC exe that is dialog based, but that for some reason (don't know what I changed) it is not being able to DoModal().
On the application's InitInstance() this happens:
CGridCtrlDemoDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { } else if (nResponse == IDCANCEL) { } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE;
nResponse returns IDCANCEL.
On the creation of the CDialog, MAKEINTRESOURCE(nIDTemplate) returns a pointer which does not allow to read the charatacters...
So, it might be a resource problem??
Can I share it in OneDrive?
Regards,
Juan
Juan Dent
Programming Setup: C++, MFC, Unicode,
single byte character set
Programming with: VS 2015
Computer: Windows 10
Issue:
I need to get the path of the Users executing this application.
Example: C:\Users\joliv\...
I need a function that returns "joliv" (or I could also get "C:\Users\joliv". I don't know if I'm using the correct terms or not so let me tell you what I've done. I started using: GetComputerName(infoBuf, &bufCharCount). This was an obvious wrong.
TCHAR infoBuf[INFO_BUFFER_SIZE]; DWORD bufCharCount = INFO_BUFFER_SIZE; if (!GetComputerName(infoBuf, &bufCharCount)) return false; ... Do Work ...
then GetUserName(infoBuf, &bufCharCount)
char szUser[50]; char* pTemp = NULL; memset(szUser, 0, sizeof(szUser)); pTemp = _dupenv_s(szUser("USER")); if (pTemp != 0) { strncpy(szUser, pTemp, sizeof(szUser)); pTemp = NULL; } .... Do other work .....
I haven't coded in 10 years so I'm rusty The code above gives me errors. My understanding is that programmers no longer use "char" like the old days.
so I get confused if I should always use TCHAR. My understanding is that it is better to use single byte character
set
What is strange is that... GetUserName( ifoBuf, &bufCharCount) works on one computer (laptop) but not on my Test computer (both running win 10. This is baffling. The code below can work if "rfid" = "FOLDERID_AccountPictures" which
gives me a super long string. I could manipulate the string to get everything up to the second "\\" (slash). But that seems like a hokey way to code.
if (E_FAIL == SHGetKnownFolderPath(rfid, 0, NULL, ppszPath)) { MessageBox(_T("SHGetKnownFolderPath Error")); return false; }
.... Do other work ....
Any help is appreciated. Thanks
JCO
I'm working with a large old dll which uses Python24 and Boost-1.32.0. The makefile uses the Microsoft Visual C++ Toolkit 2003 cl.exe which works but it would be nice to go with C++ 11 and more modern secure functions. Every other compiler I've tried to date does not like the fact that there are variables which are not declared. Below is an example of what I mean:
1>CvGameInterface.cpp(1997): error C2065: 'iI' : undeclared identifier
aFlyoutItems.push_back(CvFlyoutMenuData(FLYOUT_CONSCRIPT, iI, pPlot->getX_INLINE(), pPlot->getY_INLINE(), szBuffer));
Changing things would take considerable time so is there either a compiler which is compatible with Python24, which I can use with the makefile or is there a way to make modern compilers ignore the undeclared variables? I'd be grateful for any help.
Thanks, Chris.
Hello
I have the followed Problem. I have a MFC Desktop application running under Windows 10 and I'd like to improve the touch / pen capabilities.
Windows 10 itself and also i.e. the file Explorer Supports in a good way the touch / pen capailities. When I touch the Screen and keep the finger on the Screen a surrounding square is displayed. If the square is displayed I know if I remove the finger a context menu will be displayed.
The same with the pen capabilities. I Keep the pen on the Screen, the Little circle will Close, if I than remove the pen the context menu is displayed.
I am assuming this is a General Windows functionality. I tried RegisterTouchWindow, but the square for touch and the circle for pen events does not Show up. Is there a Special API to have this Feature or what am I missing? Most Microsot Desktop applications have this Feature. Also Notepad Supports this.
My question is how can I implement the above described Feature?
Best regards
Bordon
Note: Posted code pieces may not have a good programming style and may not perfect. It is also possible that they do not work in all situations. Code pieces are only indended to explain something particualar.
LinkedList.h
#pragma once template<typename Type> class LinkedList { private: struct Node { Type item; Node* next; Node(const Type&); Node(const Type&,Node*); ~Node(); void* operator new(size_t); void operator delete(void*); }; Node* pointer; public: class Iterator { private: Node* pointer; public: Iterator(LinkedList&); bool operator++(); Type& operator*(); Type& operator->(); operator Type*(); operator bool(); }; LinkedList(); bool Add(const Type&); bool Remove(const Type&); bool Delete(const Type&); Iterator Begin(); //The syntax error I get relates to this line ~LinkedList(); };
LinkedList.cpp
#include "stdafx.h" #include "LinkedList.h" template<typename Type> LinkedList<Type>::LinkedList() : pointer(nullptr) {} template<typename Type> LinkedList<Type>::~LinkedList() { if (this->pointer != nullptr) delete this->pointer; } template<typename Type> bool LinkedList<Type>::Add(const Type& item) { return this->pointer = new Node(item,this->pointer); } template<typename Type> LinkedList<Type>::Iterator::Iterator(LinkedList<Type>& l) : pointer(l.pointer) {} template<typename Type> LinkedList<Type>::Iterator LinkedList<Type>::Begin() { return Iterator(this->pointer); } //The syntax error I get relates to this line
For these codes above I get this:
syntax error: identifier 'Iterator'
What's the problem C++ compiler? I have already defined this class inside LinkedList class, which I also defined in LinkedList.h, and I #include it here in LinkedList.cpp. Are you trying to tell me that 'Iterator' is undefined or what else? I don't understand you please explain already!
My code formats a message for when a dll cannot be loaded.
dllMod = LoadLibrary(_T( "USERDLL.dll" ));
if ( dllMod != NULL ) { // load for all processes
userdllinit( );
} else {
LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
// Display the error message
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
(lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)LoadLibrary) + 40) * sizeof(TCHAR));
StringCchPrintf((LPTSTR)lpDisplayBuf,
LocalSize(lpDisplayBuf) / sizeof(TCHAR),
TEXT("%s failed with error %d: %s"),
LoadLibrary, dw, lpMsgBuf);
MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK);
LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);
}
If there is no dll available, it gives this message:
How can I get rid of all the garbage? I only want the message itself.
Guys,
Where/what is the point at which MFC application finished everything with regards to initializing/loading itself and it is awaiting for input from the user?
Is there a method which indicates that state has been reached?
Thank you
I want to update a MySql database from a Windows application that is written in Visual C++. I have used the article "How to simulate a Form POST request by using WinInet" for guidance and changed it to the GET request. There were no updates made to the database. I changed the code to use the localhost for test purposes.
void COnlineProView::HTTPFormGetRequest(CString szFormData) { CString szHeaders = _T("Content-Type: application/x-www-form-urlencoded"); CInternetSession session; CHttpConnection* pConnection = session.GetHttpConnection(_T("localhost")); CHttpFile* pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET, _T("localhost/aws.php")); BOOL result = pFile->SendRequest(szHeaders, (LPVOID)(LPCSTR)szFormData, szFormData.GetLength()); }
My aws.php is a simple program that prints the $_GET array. When I run my application, I don't get to see any output from aws.php in my browser. I will say that I am a complete novice at passing data via the internet so I'm not completely sure that I'm looking in the right area. I would appreciate any advice. Many thanks.
I have a large MFC application that I have made High DPI aware. I have all my windows and dialogs scaling based on the dpi of the monitor they are being displayed. The windows 10 anniversary update helped with things like non client scaling, but I have some big issues with checkboxes and radio buttons. The fonts on these controls have been scaled correctly. but the glyphs for the square or circle are either too large or too small. If the main display is at 250% (4k) and another display is at 100% the checkbox square is WAY too big on the other display on both windows and dialogs. If the main and other display scale factor is switched, then the checkbox square is too small.
Is there something I can do in my application or is this glyph drawing totally an issue with Windows itself or is it an issue that needs to be solved by Microsoft?
Reference articles used:
https://msdn.microsoft.com/en-us/library/windows/desktop/dn469266(v=vs.85).aspx
https://blogs.technet.microsoft.com/askcore/2015/12/08/display-scaling-in-windows-10/
https://blogs.windows.com/buildingapps/2016/10/24/high-dpi-scaling-improvements-for-desktop-applications-and-mixed-mode-dpi-scaling-in-the-windows-10-anniversary-update/#Hra3ASt46fOszMRg.97
Thanks
My dll loads and runs perfectly on a desktop and laptop PC. When my customer tries to run it on a tablet PC, the LoadLibrary() function comes back with error 126, module not found. His configuration is
Windows 10 Home
Version 1511
OD Build 10586.589
...
Processor x5-Z8300 CPU...
Ram 2.00 GB
System type 64-bit, x64 processor
The dll was compiled on a 32-bit OS. Could that be the problem? I know you can't go the other way.
Can you figure out why this will not load?
Hi, All
Was not sure where to post this so here it is ...
Select: File:New:Project
Select: Installed:Templates:Visual C++:CLR:CLR Empty Project
Wait for it to load ... And some!
In Solution Explorer, Right Click the Project.
Select: Add:New ITem
Select: Installed:Visual C++:UI:Windows Form
Select: Add
KaBoom ... The data necessary to complete this operation is not yet availiable. (Exception from HRESULT: 0x8000000A)
From this point forward, the Designer is gone ... Restart VStudio (even OS), Re open the project and no designer.
Is there a solution.
The form .h file:
#pragma once namespace Deleteme { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Summary for MyForm /// </summary> public ref class MyForm : public System::Windows::Forms::Form { public: MyForm(void) { InitializeComponent(); // //TODO: Add the constructor code here // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~MyForm() { if (components) { delete components; } } private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->components = gcnew System::ComponentModel::Container(); this->Size = System::Drawing::Size(300,300); this->Text = L"MyForm"; this->Padding = System::Windows::Forms::Padding(0); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; } #pragma endregion }; }
EDIT: ooPs, Sorry, forgot os: Win7
Thank you
-Enjoy
fh : )_~
Hi Folks:
Developing on Windows 10 Pro, Visual Studio 2015 Community, all C++.
Is there some way to inform a dialog procedure that the repaint initiated by the dialog procedure's WM_PAINT message has finished?
I've tried posting a message of mine to the dialog at the end of the WM_PAINT clause, hoping the dialog would receive it after the repaint was finished, but the dialog receives it before the dialog is repainted.
I've looked, but haven't found a message the system sends to my dialog informing it that the repaint is finished.
Thanks
Larry