C++

57K

Solutions

24K

Contributors

C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.

Share tech news, updates, or what's on your mind.

Sign up to Post

I need to read a jpg file and convert it in a hex string in c++ 6.0 beacuse i need to create an rtf file with image but with fieldinst i can't resize the dimensions of the image.
0
It seems that the CFileDialog functionality has changed after .net 2003.

When I invoked the CFileDialog to browse in .net 2003 This line of code (see below) returned a pointer to the file browser window but in .net 2005 and .net 2012 it returns null.

How do I obtain the browser dialog window pointer in VS 2012?

Question:

 CWnd *pp = GetParent();                          


I have a class

class MyFolderBrowser : public CFileDialog

Which is derived from CFileDialog.

I construct it and invoke it from a function as follows:

 MyFolderBrowser browser(m_projectBasePath);
   if (browser.DoModal() == IDOK)
   {
      m_projectBasePath = browser.GetPath();
      OnChangeProjectName();
   }



The DoModal invokes this code:

void MyFolderBrowser::OnFolderChange()
{
    CWnd *pp = GetParent();                          
    VERIFY(pp);
    ASSERT(::IsWindow(pp->m_hWnd));

    ASSERT(pp->GetDlgItem(IDC_MC_DIR) != NULL);



In .net 2003 this call: " CWnd *pp = GetParent(); "

would return the browse dialog window pointer,. but in .net 2005 and later it returns a null.

How doi I get  the pointer to the file dialog window in .net 2012?
0
Hi Experts,

I am making a call to _wfopen_s and getting access denied.  I'm trying to open with readonly.  I know the file is already open for writing from a call to CreateFile - and CreateFile has the flag set for sharemode=FILE_SHARE_READ.  Any idea why I can't open for reading?

Thanks!
Mike
0
So I have inherited and must finish some code written by a departing developer.  In going through it I saw the code below.  The intent is fairly obvious (or at least lets assume it is how it looks), it is trying to set flags on the transition of the PressureTimerStatusBit.

It jumped out at me because it uses '&' instead of '&&'.  To me the logical operator is more appropriate here, you should never mix and match logical tests and bitwise operators, because you can get unexpected results like 6&1=FALSE.  On the other hand, maybe its okay because all operands are boolean or 1/0.

I am trying to touch as little working code as possible, so I'm torn: should I 'fix' it (replace '&' with '&&') or is [dont mix and match logical and bitwise] not a hard and fast rule?

Thanks for any thoughts.


if (oldPressureTimerStatusBit == 0 & PressureTimerStatusBit == 1)  // these are bools
{
   self.thresholdTrippedHi = 1;
   _isPressurized = true;
}

if (oldPressureTimerStatusBit == 1 & PressureTimerStatusBit == 0)
{
   self.thresholdTrippedLo = 1;
   _isPressurized = false;
}
oldPressureTimerStatusBit  = PressureTimerStatusBit ;

Open in new window

0
Hi Experts,

I have a HANDLE h to a file that is open for writing.  Is there a way to create a handle to this same file for reading (while the file is open for writing), without providing the path to the file?

Thanks,
Mike
0
I hope to write a library of video processing algorithms using C++ 2011 and have that library be used at the back-end on both Windows and Web. Mac wold also be nice, but not a deal killer.

Would I use Visual Studio for this C++ compiler? Is this a different program than C++.NET? (I have an MSDN license, so I could get my hands on any of them)

Would I configure the project to C++ 2011 in order for the compiler to enforce that target platform? What features does C++ 2011 provide?

And what about C++ libraries for video processing which are open sourced?

Thanks!
0
In the following ex:

int myClass::getBeer(void)
{
  MyBuddy& refBuddy=getABuddy(true);
  refBuddy.getMoreBeer(1,2);
  return 0;
}
when refBuddy goes out of scope will it delete the actual object referenced?  I remember something horrible once happened along these lines and want to avoid a repeat performance.
0
I have a custom dll that I created some time back for a stock analysis program that has started to give me some problems.  From the error message of this question you can gather what the problem is - what I would like is a way to troubleshoot by an error log or some type of popup message that gives me more information since it might be a data issue (the dll has work flawlessly for years).

Preface: I am using vectors because I need some sort of dynamic array since I do not know how big the array needs to be when the dll is first called.

This dll runs across 8 CPU threads through more than 3000 symbols with many, many, MANY years of data.  The dll basically gets all of the dates, highs, lows and closes for and calculates based on that information.  Below is the vector portion of the code:

//This function returns how many rows in the axis to step through
double StepDown(double *range, double *retvals, double value, int arr_size) 
{
   int i; //have to declare i outside of if statement or will generate undeclared identifier error
   if (value>=0) {
      for (i=0; (i<arr_size) && (value<=range[i]); i++);
   }
   return retvals[i];
}

//Create Y Axis of Precentage Scale
void yAxis(struct WORK &chart, float maxHigh, float minLow, float percent)
{
   float Price = 1;
   int buff = 4; //buffer top & bottom of chart
   while (Price < maxHigh + buff * maxHigh * percent) {
      Price = Price * (1 + percent); 
   }
   while (Price > minLow - buff * minLow * percent)  {
  

Open in new window

0
Hi,

Can any one give me code/link for crossword puzzle solve. it need to search and find words in all direction .
0
it free its the express version but when i go to the page on the registration it tells me that that page is no longer available any one have a spare key or can get one for me
0
I tried CSmtp, and after investing much time found out it leaks memory and behaves erratically in x64.
If you know and use an email (free) class, not just did a search on Google, please share.
0
I have key inside map that is a structure.
Is this a vaid std::less I can use on map or do I have to define my own '<' operator. Correct me if I am wrong since both are uint32, my code should work. It should not have any impact on find and insert.

struct key{
	uint32 id;
	uint32 ver;
} ;
typedef struct key key;
std::map<key, uint32, std::less<key> > g_map;

Open in new window

0
This is the first time i am using OpenGl
In my MFC i did this:
Added:
#include <gl/GL.h>
#include <gl/GLU.h>
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")


Then in one of the function i call:
int err = glGetError();//err is set to 1282 even when this is the first call to opengl
      int screenStats[4];
      // get the width/height of the window
      glGetIntegerv(GL_VIEWPORT, screenStats);

      
      int err = glGetError();///err is set to 1282 even when this is the first call to opengl
and screenStats is not filled with values.


So no matter to which function i call, i always get 1282



Final goal is just to take screenshot of the screen with opengl.
I tried:
BYTE* pixels = new BYTE[ 3 * width * height];

glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);

int err = glGetError();
but again err is 1282


Should i init something before calling opengl functions?
0
How can I generate a C++ function/method call graph/tree using Doxygen, GraphViz, and Dot? The result could be a text file and I would search on a function or method name, and I would be able to see who calls it (my main interest). Who it calls is OK, since a search on a name would show the caller anyway.

I do not want to use Dynamic profiling.

I heard that Doxygen has a way to do this. If someone is familiar with that approach, maybe you would be able to help me through the steps to get there.

I am not looking to write a C/C++ program to do this. I got the impression there are some scripts to do this job.

Thanks,
Paul
0
I need to open a browser from C++.  When I do that I get the following behavior.  See code samples below:
If IE (the default browser) is already open, the program opens a new tab and proceeds to the next line of code.  It prints "Browser opened".
If IE is not open, the program opens it, the page displays, but the program does not go on to print "Browser opened".
How do I get the program to open the browser and then proceed?  I am using gcc on Windows 7.

Thank you!
Test.cpp
test.html
0
There are several ways to write/append to a file.

Method 1: Traditional C way
using int fd = open()
  write(fd....)  
  close(fd)

I recently came across this new method
Method 2:
        std::ofstream ofs(logfilename.c_str(), std::ios::out | std::ios::app);
        ofs << "DEMO" ;
        ofs.close();

Is it just more of a preference or is there any performance impact of one method above another. I was thinking of doing some profiling but just wondering if there is any good reason to stick with old method
0
I understand the difference between static (.a) and dynamic libraries (.so) used at the linkage time. However I do not understand why one is preferred over other. I see in my application that sometimes they use .a and sometimes they use .so

1) The whole point of .so is its dynamic (like DLL in windows). if a binary is lined to .so, there is no need to recompile the entire binary and restart it. One can only compile the code related to .so and just drop it on the cluster without restrating the binary.

2) However if we link the binary to the static .a library, then we need to rebuid the .a, recreate the binary by linking to new .a, then drop it to the cluster and maybe a restart is required.

Clearly static is not a good choice. So why would someone link to static library .a. I am just trying to understand some use case of it that will help me understand why we are doing that way.
0
the system is waiting till you enter the "" both before it puts them on the page
have had a look were do i turn this off so i only have to enter "and it goes in on the page
thanks for your help
0
Is there a way to programatically dismount and remount a USB drive on a Windows machine (as far back as Windows XP) without ever unplugging the device?

The idea is to block access to the USB drive from even the operation system until such time that a scheduled program needs access to it.

No one would have physical access to the computer, so it would be fine if the OS would still automatically mount a USB drive when it is plugged in so long as a command/program could be run to logically dismount the drive until such time that the scheduled task needs access to it.  (So a system that is defeated by simply unplugging and replugging the USB drive in would be fine).
0
Hi I am trying out visual studio 2013 upgrading from 2010. VS 2013 90% of the time has attach where normally the option is to run and start debugging and its also doing the same thing in release mode as well. Then sometimes VS 2013 works fine and has local debugger in the run icon and I can debug and run the app as normal, but while there is attach and only attach next to the run icon I can not run the app to debug it either in debug or release mode only compile it.
 So how do I fix this annoying issue as it was not in VS 2010 unless I specifically chose this option to attach to another process.
Regards
Nigel
0
Hello Experts,

I am not really sure how to approach this problem.  Currently I am using Ubuntu 12.04 LTE for a ARM project, which also uses a 20 pin header connector, that has a pinout assignment for a RJ45, and host USB port.  Does anyone know of any example C++ code that shows how to assign the pins programmatically for each port or any component that will allow this to be coded?

Regards,
aj85
0
I actually want to do the correct conversion, not hide the warning in the compiler.  The code uses a lot of functions that I didn't write and can't really change, so I just want to do the right conversion in the call.   Is the approach in the attached code a good solution or am I missing a better way?
cppStingToCharStar.cpp
0
I have a character array that stores both and IPv6 and IPv4 address that is inside IPv6

example)
A real ipv6 address  char client[64] =  "fe80::252:39cc:fe45:1234"
An IPv4 address inside IPv6  char client[64] = "::ffff:172.17.30.3"

Is there a way I can convert the the second address to real IPv4 address?
One way is to copy to string and use substring

but can this be done using the standard inet_ntop or inet_pton or something else.
0
I have the noticed the following in code path

#if SOME == 1
   // Do someting
#else
   // Do something
#endif

Open in new window


How can we set the variable SOME, is this something set using environment variable from the bash shell before executing the executable?
0
Hi Experts,

Does anyone know where I can get some 3d fonts (coordinates) for drawing text in OpenGL?

Thanks!
Mike
0

C++

57K

Solutions

24K

Contributors

C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.