C++

56K

Solutions

46

Articles & Videos

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

Let's say you have a COM interface,IWebBrowser2, it has a function, it has a function Navigate, Is there anyway that I can hook to this function, like I hook CreateProcess function in kernel32.dll?

Thank you for any help.

Evan
0
On Demand Webinar: Networking for the Cloud Era
LVL 8
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

I have a C++ class that needs to get information from an oscilloscope for analysis. I have the code that issues the command to the o'scope and can see the o'scope getting the info. Here is that code:

void CbeLecroy::GetScaledWF(LCHAN channel, int numpoints, VARIANT* rvals)
{
	waveform.Attach(activeDSO->GetScaledWaveform(bCHANNEL[channel], numpoints, 0));
	rvals->parray = waveform.parray;
	float* pfloatVals;
	HRESULT hr;
	hr = SafeArrayAccessData(rvals->parray, (void**)&pfloatVals); // direct access to SA memory

	if (SUCCEEDED(hr))
	{
		long lowerBound, upperBound;  // get array bounds
		SafeArrayGetLBound(rvals->parray, 1, &lowerBound);
		SafeArrayGetUBound(rvals->parray, 1, &upperBound);

		fvec.clear();

		long cnt_elements = upperBound - lowerBound + 1;

		for (int i = 0; i < cnt_elements; ++i)  // iterate through returned values
			fvec.push_back(pfloatVals[i]);

		SafeArrayUnaccessData(rvals->parray);
	}
//	SafeArrayDestroy(psa);
}

Open in new window


The calling function looks like this:
    VARIANT rvals;
	comLecroy->GetScaledWF(channel, numpoints, &rvals);

Open in new window


When I breakpoint in the top function, I can see valid data in the loop:
		for (int i = 0; i < cnt_elements; ++i)  // iterate through returned values
			fvec.push_back(pfloatVals[i]);

Open in new window


However, when I exit the called function and return to the calling function, I get an exception. Any ideas why?

Thanks, Brian
0
I want to write an application that can read/query Windows Explorer and list multiple files that are selected. My program will launch from the right-click context menu.

I have tried by reading the command line using GetCommandLine(), and that works fine. Except it launches a new instance of the program for each file selected.

Some guidance would be appreciated.
0
Hi,
I have a problem with custom templates not creating solutions correctly. It works fine on my Home computer but not on my office computer. I have reinstalled VS 2015 several times but problem remains. The issue is the "Location" and "Solution Name" dialog are not visible nor are the "Create directory for solution" or "add source to control" checkboxes and browse button.

Below is an example of what happens and below is one of the template files (this effects several new project templates under c++).

If I select New -> Visual C++ -> Empty Project, I get the following dialog at bottom of window (You can see that "Location Field" is Enabled and yet it does not show when I create a new project)



Name: Project 1
Location: C;\users\david\visual studio 2015\projects
Solution Name : Project 1
Also a "Browse" button, "Create directory for solution" checkbox and "add to source control" checkbox.

If I select New -> Visual C++ -> Particle Project (which is one of the custom projects) I get

Name : Sketch1

All the other dialogs and checkboxes are missing.

BUT, When I am on my computer at HOME, I see all the correct solution name, location and checkboxes ok, but NOT on my OFFICE computer.

I am sure it is related to some setting in a file somewhere that is overriding the parameters for the VM template but don't know which file will be controlling this behavior.

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" …
0
My work Environment :Qt 5.8 MSVC2015 64bit, QT GraphicsView, QGraphicsRectItem, Windows 7 64 bit.

Issues : When I zoom in & zoom out on GraphicsView, I call GraphicsView scale method. But When I add QGraphicsRectItem to scene it failed to call its paint method.

my class hierachy :

  class GraphicsView : public QGraphicsView
  class mySquare : public QObject, public QGraphicsRectItem
  class Scene : public QGraphicsScene 

Open in new window

Code :

//////*****Draw Rect in QGraphicsRectItem *****////////////

void mySquare::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
      QRectF rect(0,0,_width,_height);
      painter->drawRect(rect);
}

Open in new window


 
 void GraphicsView::wheelEvent(QWheelEvent * event)
{
    int angle = event->angleDelta().y(); // angle will tell you zoom in or out.
    double scaleFactor = 1.15; //How fast we zoom
    setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
    if (angle > 0)
    {
        qDebug()<<"Zoom in";
        scale(scaleFactor, scaleFactor);
    }
    else
    {
        qDebug()<<"Zoom out";
        scale(1.0 / scaleFactor, 1.0 / scaleFactor);
    }
        mySquare  _square = new mySquare(0,blankImage);
       _square->setPos(QPointF(0, 0));
       //add square to scene. 
] //Bug!!! Why after scale function call, _square failed to draw rect in paint method.
]        _scene->addItem(_square);
        _square->update(); 
}

Open in new window


My git gitcode
I spend days & hours but still not able to find out why it QGraphicsRectItem failed to print, when scale method get called. Any suggestion is highly appreciated ?
0
I have installed a C++ add-on to Visual Studio that enable code to be developed for Particle Electron and Photon devices. I have an issue that I believe is more related to Visual Studio than the plug in.
First I installed the plug-in on my home PC (running Windows 10, 64 bit OS) and VS 2015. All worked fine.
I then copied the same steps on my office PC (also running Windows 10, 64 bit OS) and VS 2015 but when I attempt to create a project I get no option to enter solution name or location and the checkbox to create a directory is also gone. When I proceed, I get a project but no solution and then I can never save the project. I can only exit VS if I discard the project.
What-is-should-look-like.JPG
what-is-does-look-like.JPG
0
Hi All,

I want to change the face color of property sheet wizard button. The wizard has ID_WIZNEXT, ID_WIZFINISH and other default button. the button label and position is changed. i want to change the color of this default button.

class CDiskSanPropertySheet : public CPropertySheet
{
}


BOOL CDiskSanPropertySheet::OnInitDialog()
{
      CPropertySheet::OnInitDialog();

        CButton *tmpButtonNext = reinterpret_cast<CButton *>(GetDlgItem(ID_WIZNEXT));
      CButton *tmpButtonFinish = reinterpret_cast<CButton *>(GetDlgItem(ID_WIZFINISH));
      CButton *tmpButtonBack = reinterpret_cast<CButton *>(GetDlgItem(ID_WIZBACK));
      CButton *tmpButtonCancel = reinterpret_cast<CButton *>(GetDlgItem(IDCANCEL));

        buttonString.LoadStringW(IDS_TEXT_BUTTON_NEXT);
      tmpButtonNext->SetWindowTextW(buttonString.GetBuffer());
      
      buttonString.ReleaseBuffer();

        LONG rightPos, nextRightPos;
      
      //inc. to 1.7 for greek issue
      MoveButton(tmpButtonCancel,shiftFactorX, 1.7,NULL,tmpButtonNext,&nextRightPos);
      MoveButton(tmpButtonFinish,shiftFactorX, 1.7,NULL,NULL,NULL);

      rightPos = nextRightPos;

      MoveButton(tmpButtonNext,shiftFactorX, 1.7,&rightPos,tmpButtonBack,&nextRightPos);
      
      rightPos = nextRightPos;
      
      MoveButton(tmpButtonBack,shiftFactorX, 1.7,&rightPos,NULL,NULL);

}

HBRUSH CDiskSanPropertySheet::OnCtlColor(CDC* pDC, CWnd *pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CPropertySheet::OnCtlColor(pDC,pWnd, nCtlColor);

    COLORREF myColor = …
0
I installed C++ builder 6.0 on windows 10.
when I reopen a project , my working directory don't change to new project path and my new forms create on the directory that last time I used "FILE->Open Project" method.
if every body knows how can say to it change to the project path after reopen .
-- thanks reza
0
Hello Experts, I have a routine in a C++ application the creates a named  shared memory view of a structure:

struct TEST_STRUCT
{
	long 			tnum;
	unsigned long 	pass_count;
	unsigned long 	fail_count;
	unsigned long 	try_count;
	double 			sum_result;
	double 			sumsq_result;
	double 			min;
	double			max;
	unsigned 		histogram[HISTOGRAM_SIZE];
	bool 			tested;
	bool 			passed;
	double 			last_result;
};

Open in new window


The C++ application puts data into the named shared memory structure and then sets a windows named event for another process to read the same structure. That other process was written in C++ and works fine. I now need to do the same thing as the reading process, but in c#. Can you tell me how to create a TEST_STRUCT variable in c# that can be used to access the C++ named shared memory?

Thanks, Brian

Windows 7 Pro
VS2013
0
the array has series of numbers Need to find all pairs in the array using a hash table
integers ...
0
Independent Software Vendors: We Want Your Opinion
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

I'm making windows form called form2.h that has a trackbar and a label on it. I've pass the trackbar value to the label

System::Void trackBar1_Scroll(System::Object^  sender, System::EventArgs^  e) {
                        label2->Text = String::Concat( "", trackBar1->Value );
                   }

I also have a cpp file called form2.cpp and I want to use label2 from form2.h in my cpp file.
for example
string hmin = label2;
cout << hmin;

How do I do that? I already include things like

#include "StdAfx.h"
#include "Form2.h"
#include "stdio.h"
using namespace messagebox;

on top of the cpp file but I still cant use label2 element
0
I wish to implement interactive gesturing (Zoom)  in an android application that uses an FMX TGrid control. so far I have not succeeded.

The Embarcadero documentation for enabling Firemonkey  Interactive gesturing is as follows :
Enabling Standard Gestures To add support for standard gestures for a control, you need to do the following:

In the Form Designer, add a TGestureManager to the control you want to enable for gestures. Either give the GestureManager a unique name or just use its assigned name, such as GestureManager1.
In the Object Inspector, assign the TGestureManager in the Touch | GestureManager field of the control.
In the Object Inspector, select the specific custom gesture(s) from the Touch | Gestures field of the control.
Implement the OnGesture event procedure for the control and handle the appropriate EventInfo.GestureId.

I am stuck in " Implementing the  OnGesture event procedure for the control and handle the appropriate EventInfo.GestureId"

Any help would be appreciated.

I am using C++ Builder XE10.1 Berlin
0
Hello,
i sukkel with a problem,
whit i add a void call.

for a good look you can view the print screen.

HDC hdc;
TCHAR halloworld[] = _T("Hallo World\n - nadir81");
....
..
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);

		
TextOut(hdc, 10, 10, halloworld, _tcslen(halloworld));

//  The Test void i need to add. 
 test( 20,20 , "text"); 
		
		
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);



void test(int x, int y,const char text_valuta)
{
	HDC hdc;
	TextOut(hdc, x , y , text_valuta, _tcslen(text_valuta));

}

Open in new window

Capture.GIF
0
Hi,

I have "tree" include file that not wanna associate with the cpp file.
..
.....
#include <stdio.h>
#include "../sys/pcsc.h"  <<  fatal error C1083
#include "/sys/util.h"  <<  fatal error C1083
#include "sys/clessCardType.h" <<  fatal error C1083
....
..

i tried three different ways to link the in the cpp file.

print screen added
Capture.GIF
0
I want to invoke a python script from my C++ app and get the data from the python script into my C++ app. How do I do this?

example: testing.py   reads data from and ADC -

C++ app - invoke testing.py  ; data = python testing.py
0
Hi guys.

I have Form1.h and Test.cpp files in my project which was generated by VS. I have around 5 functions in my Test.cpp file and each function has to update the label with its result. I've made the label1 public on my Form1.h file and with this solution I am now able to write to the label1 outside the h file, I mean I can write to the label1 from .cpp file but only when the application is starting up or should I say only from the main function. I've used the solution provided on this post here and now my problem is that I can not use the same approach on other 5 to 6 functions as this approach also uses the
Application::Run(form);

Open in new window

which I don't think is appropriate to keep calling this from each and every function that needs to update the label.

The updates are based on the App returned results for each and every function its execute.
0
Hello Experts,

I wasn't sure what the terminology for this is, so I will use a CPP example:

class CA
{
public:
   void setvalue(double newvalue);
};

class CB
{
public:
    void setvalue(double newvalue);
};

class CMainClass
{
public:
        CA* Aobj;
        CB* Bobj;
};

later in my main code I would do this:

CMainClass* my_main = new CMainClass;  (assume that the objects Aobj and Bobj get created in constructor)

my_main->Aobj->setvalue(2.0);
my_main->Bobj->setvalue(3.0);


The above code is simple and pretty straight forward. Now the question, Can I do this as a ATL COM server? That is, have a ATL COM class that is used like CMainClass, with object in it that represent CA and CB (but in ATL COM format).

And please let me know what the terminology is for this kind of objects inside another object.

Thanks, Brian
0
Hello I'm using C++ builder 10 and I need to bold (highlight) the last value that comes into advmemo from  advcombobox/advedit.
Maybe somehow with using AdvMemo->SyntaxStyles->HighlightStyle?
0
can you help me to solve this problem?
Assume there are 5 students in a class. Each semester 3 exams are
taken by each student. Create functions to determine the class
average, highest grade and lowest grade for each exam. The
requirements are –
1) Create a function to read in 3 grades for each student. A two
dimension array int stuGrades[TOTAL_STUDENTS][TOTAL_TESTS] must be
used to hold all the grades for each exam for all the students, where
TOTAL_STUDENTS and TOTAL_TESTS are defined as –
const int TOTAL_STUDENTS=5;
const int TOTAL_TESTS=3;
2) Create a function to print out students’ grades.
2) Create a function to determine the class average, highest grade and
lowest grade for each exam.
3) Create a function to print out the results for each test.
The following functions should be defined/implemented and called in
main() –
void readStuGrades(int stuGrades[][TOTAL_TESTS]); //make sure to
validate each grade. Grade must be in between 0 and 100.
Void printStuGrades(int stuGrades[][TOTAL_TESTS]);
void getExamAvgMinMaxGrade(int stuGrades[][TOTAL_TESTS], int exam,
float &avg, int& low, int& high);
void printExamStatistics (int exam, float avg, int low, int high);
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

This question is for Visual C++ MFC application in Visual Studio Community 2015 under Windiws 7.

When you set some text in multi line CEdit box in OnInitDialog function, that is called to initialize dialog's controls. the text is displayed as selected (highlighted.) No manipulations with CEdit interface in OnInitDialog can't remove this highlighting (Like using SetSel(-1,0).)  
Somebody knows how to initialize CEdit with no selection?
0
I am looking for a piece of software that will let you select a USB device and convert its output signals (when buttons are pressed on the device) into keystrokes or configurable macros.

In more detail, I have this remote control (more accurately, a USB handset/phone) that sends USB signals depending on which button is pressed and the software I currently use converts those signals into keystrokes or macros. The software I currently use however is extremely limited, non-configurable and obsolete.

Any help is greatly appreciated!
0
I have a USB UP-90 phone which appears to just use Windows drivers for 'speakers' and a 'microphone'.

http://www.made-in-china.com/showroom/hedychan/product-detailCHmxnUQDmEKV/China-USB-Phone-UP-90-.html is the USB phone.

https://www.voiptalk.org/products/pdf/usb_phone_manual.pdf is the manual and it comes with its own software.

The software is very simple, where you select the software you use. It is compatible with Skype, X-Lite and other software. It appears this software is written in C++ and from what I can see all it does is macro certain packets from the USB device to the selected software.

I am trying to get this USB phone to be compatible with a software named PhonerLite. I used a program to rename the window title of PhonerLite to X-Lite, so the phone software thinks PhonerLite is X-Lite and therefore transmits those packets to PhonerLite.

This is a relatively good solution as when I pick up the USB phone from its hook, it will open the software and instantly I can hear the dial tone and will close the software when phone is put back on hook.

There is, unfortunately, some incompatibilities though (as expected, seeing as it's a completely different software to X-Lite). The keypad doesn't work and call will not automatically answer when picking up the phone from the hook.

Does anyone know of any software that would be compatible with this USB phone that could replace the software that comes with it? As it seems pretty limited and, if I can sniff …
0
I'm beginner in openGL , How can i change my object from smiley face to sad face then surprise face using the time?
0
Hello,

I try to load my driver with following code..

	bool rt = Privilege(L"SeLoadDriverPrivilege",true); // I got SeLoadDriverPrivilege privilege

	HINSTANCE hDll = LoadLibrary(_T("c:\\windows\\system32\\ntdll.dll"));
	*(FARPROC *)&NtLoadDriver = GetProcAddress(hDll, "NtLoadDriver");
	_LSA_UNICODE_STRING drv = toLsaUnicodeString(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\\DemoDriver32");
	NTSTATUS ntStatus = NtLoadDriver(&drv); // --> returns 0xC0000033
	freeLsaUnicodeString(drv);

Open in new window


Registry of "\\Registry\\Machine\\System\\CurrentControlSet\\Services\\\DemoDriver32" includes followings..

ErrorControl  1
ImagePath     full_path_to_my_driver --> exists and signed both 32&64
Start  3
Type  1
Group  base

Any hints welcome
0
Hi,
I've just installed Visual Studio 2015, in order to rely on it's Diagnostic Tools, to find memory leak in my C++ x64 Console application.
The tools work fine except the fact that taking a snapshot the heap view always show only unresolved allocations. The code is compiled with debug flags enabled, but not using a CRT debug version, due to compatibility issue with other dll used by the program. Is there a way to see in heap view the type and the content of each allocation?
0

C++

56K

Solutions

46

Articles & Videos

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.