w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » VISUAL C++ » Page 1
Variable setting from InitInstance()?
MFC provides the global function AfxGetApp() which returns a pointer to your CWinApp object. Cast that pointer into a pointer to your app class, then it can be used to access public members of that class. #include "YourApp.h" CString s = ((CYourApp*)AfxGetApp())->m_appCString;

Categories : Visual C++

OpenSceneGraph - Texture on each face of model
This all boils down to the texture coordinates that were assigned to the model's vertices when it was built. If you convert cube.3ds to .OSG or .OSGT text format you can see the UV coordinates that the texture mapper uses to determine where in the texture map to look for each corner of each face. This is how textures are "pinned" to faces. Just load and edit that cube or pyramid in a 3d modeling

Categories : Visual C++

visual studio 2013 C++ - console output not visible
Add a cin.get() like so: int main() { cout << "Hello world"; cin.get(); // <- Waits for any key press directed at the console window return 0; }

Categories : Visual C++

Qt static library in windows phone 8.1 application
Found one solution to the issue. Turns out windows app was not able to find Qt5Core.dll. The only solution to this issue I could find is to manually add this dll to windows app project in visual studio (Right click on project -> Add existing item) with 'Copy to output directory' property set to 'Copy if newer/Copy always'.

Categories : Visual C++

Outlook bar auto size to tree control
Solution I'm happy i found it because this is something i would have to do too in the future, you need to use CWnd::SetWindowPos to change the CMFCOutlookBar's size, check this tutorial that has more infos, after you change the size of CMFCOutlookBar you will have to use CFrameWndEx::RecalcLayout method of the frame that contains the CMFCOutlookBar. Why using CWnd::SetWindowPos? i don't know, i

Categories : Visual C++

Displaying results in c++
first of all your code is not working. 3.cpp:40:18: error: request for member ‘nrcrt’ in ‘group’, which is of non-class type ‘student [3]’ if(group.nrcrt[i]!=0) i is also not declared.please make proper changes. group.nrcrt[i] should be changed to: group[i].nrcrt

Categories : Visual C++

C++ GetClipboardData crashes when an image is copied to the clipboard
1) Try to move "}" two lines lower to avoid acess to not initialized variable: HANDLE clip; if (OpenClipboard(NULL)) { clip = GetClipboardData(CF_TEXT); CloseClipboard(); string text = (char*)clip; // still wrong line, read lower cout << text; } 2) Casting of clip to char* is wrong. There must be special function for extracting of text (read comment from Igor Tandetnik about it; a

Categories : Visual C++

error C2079: 'room::goldC' uses undefined class 'goldContainer'
Let me show you the problem domain: class Moon; class Sun { void Rotate(Moon); }; Now, you implement Sun::Rotate, without giving any class declaration (not forward declaration): void Sun::Rotate(Moon m) // Error C2027 { } What you can do: Ensure that before Sun::Rotate gets into compilation phase, Moon is declared (i.e. known to compiler by now). You need not to implement any method

Categories : Visual C++

MSVCRT backwards compatible?
No. CRT or MFC is not backward compatible. You must install appropriate Visual C++ Runtime on client's machine, ensuring that: The version should match (VC7, VC8,.. VC14 etc.) The bit-ness should match. If your application is 32-bit, you need 32-bit redistributable, and same for x64. The service pack version must also match! It should be noted that all of them can co-exist! VC10 RTM, VC10 SP2,

Categories : Visual C++

visual c++ - "function already has a body"
Definitions normally don't belong into header files. You can declare and define your function inline, inside your include guards You can use a cpp file That said, your code looks fishy. It does not do what it seems to do. There is no assignment to this or it's variables happening. But that's a bug and not a compiler error.

Categories : Visual C++

Intellisense error when using `__FUNCTIONW__`
This bug is already made public to Microsoft. Intellisense generally seems to have problems with macros even in VS2010 ( self defined or built in ) You should be okay ignoring the error for now. Also this might give you some insight in what I mean.

Categories : Visual C++

Releasing OpenSSL resources: SSL_CTX_free
Answers: Yes, you are correct Yes, you are correct Yes - as long as X509_STORE_add_cert succeded. In other words: if X509_STORE_add_cert returned value greater than zero - ownership of the X509 object is passed on the the certificate store; if X509_STORE_add_cert returned zero - ownership of the X509 object is not passed on the the certificate store - you need to handle that. Yes - if the certif

Categories : Visual C++

Does CTreeCtrl::DeleteItem also delete all the node's sub-tree HTREEITEMs
From MSDN Docs on CTreeCtrl::DeleteItem where it says If hitem has the TVI_ROOT value, all items are deleted from the tree view control, I would infer that it will alo delete sub-nodes...

Categories : Visual C++

C++ - Tab control - & character
Well, Unicode is a mountain of special characters, have some fun googling "zalgo". But the behavior of the & character, and just that particular one, is nailed down as special in the DrawTextEx() winapi function. Note the DT_HIDEPREFIX option, explicitly dedicated to controlling the behavior of strings containing the & glyph. Not an accident, accurately underlining a single character is

Categories : Visual C++

cin unintentionally skipping user input
Rather than debug your current program you might want to consider using the standard library to simply things #include <iostream> #include <string> #include <bitset> #include <climits> #include <limits> template<typename T> void get(T& value) { while (!(std::cin >> value)) { std::cout << "Invalid input "; std::cin.clear(); std::ci

Categories : Visual C++

Generate 50 random numbers and store them into an array c++
First of all we want to use std::array; It has some nice property, one of which is that it doesn't decay as a pointer. Another is that it knows its size. In this case we are going to use templates to make populateArray a generic enough algorithm. template<std::size_t N> void populateArray(std::array<int, N>& array) { ... } Then, we would like to remove all "raw" for loops. std::

Categories : Visual C++

Write a program that prompts the user to enter two characters and displays the major and status represented in the characters
For starters, in (major_in == "M") major_out == M; you have major_out == M. This is not how you assign data to a variable. It should be major_out = M. Remove the second = sign. Should also change the double quotes into single quotes ('M') since it is a character and not a string of characters. So, it should now look like : if(major_in == 'M') major_out = M; Make these changes to the rest of the

Categories : Visual C++

Get dialog window handler
You've tried to get the HWND of the object before the dialog has been created with DoModal - that won't work. And since DoModal won't return until the dialog has been destroyed, you can't do it after. You'll have to find another point where you can capture that handle. P.S. Don't call SendMessage from another thread. You're asking for trouble. Use PostMessage instead.

Categories : Visual C++

Deadlock in two forms
The reason is simple: You didn't used m_pMainFrame in the second thread. What happens: Click on the button in your MyApp Thread. The message is sent to the second window. The current MyApp thread is suspended until the second thread will return. In the second modHolder thread. The message is received by the message loop. Your handler is called and AfxMessageBox is launched. The internal code fo

Categories : Visual C++

Type conversion from BYTE* to int* in VS C++
Your problem is here: LONG lBytesToMP3=lame_encode_buffer_interleaved(gfp, reinterpret_cast<short int*>(pData), nNumFramesToRead, mp3_buffer, MP3_SIZE); You are passing 8-bit sound data to lame_encode_buffer_interleaved when it is designed to take 16-bit sound data. The fact that you are casting your data via reinterpret_cast<short int*>(pData) should make it clear. You need to act

Categories : Visual C++

CWnd.wndTopMost usage
wndTopMost is only used for the first Parameter of SetWindowPos. This variable is used to insert a Window in the Z-Order after this window. So it is alowed to be defined as const, because the window it self is not modified. Internally it is just a Special handle with the value -1 (look here) And with this trick (const CWnd) nobody can do something you tried. If you really want to do something

Categories : Visual C++

A sample https client request c++ program to invoke using gsoap
Proxy class which is generated provides the cafile and ssl_flag, so we can pass the certificate that verifies the certificate in https like this : BindingProxy *Service = new BindingPRoxy(); Service->cafile = "C:\Users\Machinename\Desktop\ca.cer"; Service->ssl_flags = SOAP_SSL_DEFAULT; This will verify the SSL certificate.

Categories : Visual C++

How can I find the length of a _bstr_t object using windbg on a user-mode memory dump file?
Your .writemem line is pretty close to what you need already. First, you'll need the correct address of the string in memory. 07a4f6e8 is the address of the _bstr_t, so writing memory at that address won't do any good. _bstr_t is a pretty complicated type, but ultimately it holds a BSTR member called m_wstr. We can store its address in a register like so: r? @$t0 = @@c++(basicString.m_Data->

Categories : Visual C++

Unresolved external symbol in libgcrypt.lib
My experience with other runtime library implementations leads me to suppose that various printf variations are implemented by calling a lower level vprintf form. fprintf was put into thay .o file (why? Isn't that itself a RTL function?) and it needs that helper function. From the name decorations, I expect that's to be found in a mingw system library. I beleive that printf functions are in a s

Categories : Visual C++

Standard Deviation Code Output Error
After running your code I found a few bugs. You probably don't get any output because the program crashes the first time through the while loop on the line: mean = sum / n; due to a divide by zero error. The other bug is that you don't increase (increment) the value of n in your loop, so you always only have one number. Adding an n++ at the beginning of your loop will fix that while (in

Categories : Visual C++

DLLs missing, application gets 0xc00007b error code
In ol der versions of vs (there is no vs2006) the dlls had to be installed in a formal way, not just present. And, there is no redistibutal package for debug dlls. You have to install visual studio, or update to vs2010.

Categories : Visual C++

How to keep a process alive in visual C++
I believe you want Process::HasExited private: Process^ proc; private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Environment::CurrentDirectory = somedir; this->proc = Process::Start("some.exe"); Environment::CurrentDirectory = "../"; } private: System::Void timer_Tick(System::Object^ sender, System::EventArgs^ e) { if (this->proc->HasExi

Categories : Visual C++

How do debug if my application has the launching issue
There could be a lot of reasons for your application's Release is crashing. Did you link proper Release libraries with your application in Visual Studio project configuration ? Check your code for some missing Release specific code. My best guess is you are not linking to proper libraries for the Release version of your application. Also, one reason could be that your application may be tryin

Categories : Visual C++

template instantiation statistics from compilers
There are several ways to attack this problem. If you are working with an open-source compiler, it's not hard to make a simple change to the source code that will trace all template substantiations. If that sounds like too much hassle, you can also try to force the compiler to produce a warning on each template instantiation for a given symbol. Steven Watanabe has written a set of tools that can

Categories : Visual C++

Integer division by zero exception isn't caught
Use /EHa to switch the exception-handling model, so non-C++ exceptions can be caught by try-catch. Be aware that all asynchronous exceptions will be converted to synchronous if you do so, and you really don't want to catch most. Thus, not recommended for general code. As an aside, blindly catching all you can is a known anti-pattern, only catch what you really expect and can handle. See here fo

Categories : Visual C++

Building 32bit Float from 4 Bytes [Binary File I/O] in C++
So with a bit of effort and Igor's comment I was able to solve the problem. The following function reads everything into a buffer vector. vector<char> buffer; void fill() { string filename = ""; cout << "Please enter a filename: >"; getline(cin, filename); ifstream file(filename.c_str()); if (file) { file.seekg(0,std::ios::end); streampos length = file.tellg(); cout&

Categories : Visual C++

Best way to handle a winsock 10004 error
Don't use multiple threads to read from a single socket at the same time. Don't use a thread to handle your timeout. All you need is a simple loop, maybe a timer. To get around the blocking issue, either put the socket into non-blocking mode, or use select() with a timeout to know when it is safe to call recvfrom() without blocking, or use setsockopt(SOL_SOCKET, SO_RCVTIMEO) to set a timeout on

Categories : Visual C++

chdir(variable) in Visual C++ will not accept string variable
As you are using C++/CLI there are managed and unmanaged (native) pointers. The managed pointers are the the ones with the caret ^ . C++/CLI is meant as a bridge between managed CLR code and unmanaged C++ so you have to convert from one to the other. In order to convert the managed String^ pointer to a native C++ pointer you can convert it with something like: System::String ^somedir = "your dir

Categories : Visual C++

VC++ 64 Bit SetDIBits does not work
The whole function can be replaced with: src->Clone() to copy the bitmap to a compatible bitmap Graphics::FromImage() to make a Graphics compatible with the clone GetHdc() on the graphics, to get an HDC for your existing drawing functions

Categories : Visual C++

Porting desktop VC++ application (using WDK) to modern(metro) application
If your app has many ties to the system, which I suspect yours does with many low level WDK calls, then those could be troublesome. I suspect your app will need to stay as a desktop app, at least if you plan to distribute it through the store. Your UI (unless it is DirectX) will need to be completely rewritten to use the HTML or Xaml libraries available to Windows Store apps. If your core logic

Categories : Visual C++

Error: Struct already definded in *.Obj
You must change your header declaration: you're inadvertently declaring a different, global "Input" variable in every .cpp that includes "Modifier.h". SUGGESTION: // Modifier.h #ifndef MODIFER_H #define MODIFIER_H struct Input { bool beg(string a) { string b; getline(cin, b); if (b == a) { return true; } else {

Categories : Visual C++

Receiving multiple sendto() from servers
After you send the broadcast, start a timer and let it run for like 5-30 seconds. During that time frame, process any replies you receive. When the timer elapses, stop processing any more replies, just discard them if you happen to receive them. No, a UDP socket cannot provide you with multiple datagrams at one time, you must read them individually.

Categories : Visual C++

MSVC2013 gets confused over calling convention of ctor
The problem is in the 64 bit build. This build was created from the 32 bit build, but MSVC does not change the library dependency in the process. As a result, the linker tried to link 32 bits function bodies into a 64 bit build. As the member function calling conventions differ, the first check to fail is the name lookup. The linker never gets to a point where it checks if its inputs are all 64 bi

Categories : Visual C++

VC++: Code works in VS2010 and breaks in VS2013
Looking at this error on my system, it seems to be only related to the #define _CRTBLD and the fstream header. The included dbgint.h is irrelevant (you can comment out that #include and still get the same error. So, this seems to be a problem in the fstream header. Changing the order of inclusion removes the compilation errors: #include <windows.h> #include <fstream> #define _CRTBLD

Categories : Visual C++




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.