Visual C++ :: Render Content Of CRichEditCtrl On Device Context Of Some CWnd?

Mar 4, 2013

I need to render content of CRichEditCtrl on device context of some CWnd. This code works ok:

Code:
CDC *dc = wnd->GetDC();
CRect cr;
wnd->GetClientRect( &cr );
dc->Rectangle(cr);
cr.right *= 15;
cr.bottom *= 15;

[Code] ...

The problem is that I want to scale the output. I was trying to send message to my control before blitting:

SendMessage( EM_SETZOOM, numer, denom ).

It scaled the control itself, but the blitted context was still the same size as original content CRichEditCtrl (befeoe scaling). Is there any way to blit/render scaled content of CRichEditCtrl to any device context (screen/paper) ?

View 3 Replies


ADVERTISEMENT

Visual C++ :: What Is The Class Name Of CRichEditCtrl

Sep 10, 2013

QUESTION: What is the class name of CRichEditCtrl? More generally, how can I figure this out myself eg with the debugger or documentation?

I've successfully made 3-4 fairly complicated controls from scratch, starting by subclassing CButton as shown in some of the associated example projects.

My current project needs a CRichEditCtrl, with just a slight bit of extra functionality.

I've always used a method called RegisterControlClass(), taken from the example projects, that filled in a WNDCLASS structure by getting another class's WNDCLASS then just modifying it a bit. To get the initial values I used the class name "button" as that was in the example program. It worked fine.

Now, to get the name of SCRichEdit, I'm stumped.

I started by examining a real CRichEditCtrl:

CRichEditCtrl* prich = (CRichEditCtrl*) GetDlgItem( IDC_PATCH );

I've tried using the debugger and looking at prich->GetRuntimeClass()->m_lpszClassName, but it equals "CWnd". Obviously wrong.

I found some docs on the 'net referring to MSFTEDIT_CLASS, which has a value of "RICHEDIT50W", that doesn't seem to work either.

I found some fields deep inside the prich object in the debugger leading me to think it might be simply "CRichEditCtrl" but alas not that either.

Here's the function with the class name "button" that works albeit isn't what I want.

Code:
BOOL SCRichEdit::RegisterControlClass() {
// STEP 1: check to see if a class is already registered with this name.
// If it is, and the WndProcHook is ours, then WE'VE already registered
// and its OK. Otherwise someone else is using the same class name. Not OK.
WNDCLASS wclsSCRichEdit;
static const TCHAR szClass[] = _T( "SCRichEdit" );
if ( ::GetClassInfo( AfxGetInstanceHandle(), szClass, &wclsSCRichEdit ) )
return wclsSCRichEdit.lpfnWndProc == (WNDPROC) SCRichEdit::WndProcHook;

[code]....

View 9 Replies View Related

Visual C++ :: How To Print Contents Of CRichEditCtrl V 2.0

Oct 5, 2012

I am trying to print the content of the CRichEditCtrl v 2.0. The problem is that when I want to use pagination (with A4 pages), the printed text (which is just 4 sample line with 40 chars at most) at the code lTextPrinted =FormatRange(&fr,TRUE); is always lesser than the actual text pointed by the lTextLength variable making the loop run for ever. notice that using the RichEditControl Version 1 it works fine.

Check the code. I am attaching also the full source code at [URL]

Code:

CPrintDialog printDialog(false);
if (bShowPrintDialog) {
int r = printDialog.DoModal();
if (r == IDCANCEL)
return; // User pressed cancel, don't print.

[code]....

View 2 Replies View Related

Visual C++ :: Main CWnd Class And Mouse Events

Jun 17, 2013

I have a main CWnd class called CMainWnd which is created like this:

Code:
DWORD dwStyle = WS_VISIBLE | WS_BORDER | WS_CLIPCHILDREN ;
...
CWnd::Create(AfxRegisterWndClass(CS_DBLCLKS), L"", dwStyle, rect, parent, NULL, NULL);

And I draw smaller windows on this main window with a CWnd-dervied class called CClientWnd, which is created like this:

Code:
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER;
...
CWnd::Create(AfxRegisterWndClass(CS_DBLCLKS), L"", dwStyle, rect, parent, NULL, NULL);

In the main window I draw lots of background stuff using a memoryDC and BitBlt(). In the child window, I actually am not drawing anything, I just created it to have events like mouse over, etc. In the child window when the mouse is over the window I bring up a pop-up window. This works unless my mouse is over any parts where something is drawn in the main window, then the popup just flickers constantly. Why is the main window affecting my mouse over events if I am not handling any such events for it?

View 1 Replies View Related

Visual C++ :: Creating CWnd With Parent Of Type CFormView - App Crashes

May 28, 2013

My app crashes when I attempt to create a CWnd as shown below. I am attempting to create the CWnd with a a parent of type CFormView. Why this might be crashing?

Code:
CWnd::Create(AfxRegisterWndClass(CS_DBLCLKS), CString(windowName.c_str()), WS_VISIBLE | WS_BORDER, dimensions, parent, NULL, NULL);

The call stack looks like this:

Code:
mfc100ud.dll!AfxGetInstanceHandle() Line 21 + 0x20 bytesC++
mfc100ud.dll!AfxRegisterWndClass(unsigned int nClassStyle, HICON__ * hCursor, HBRUSH__ * hbrBackground, HICON__ * hIcon) Line 1462 + 0x5 bytesC++

And the line that crashes here us the AfxGetInstanceHandle() call:

Code:
LPCTSTR AFXAPI AfxRegisterWndClass(UINT nClassStyle,
HCURSOR hCursor, HBRUSH hbrBackground, HICON hIcon) {
// Returns a temporary string name for the class
// Save in a CString if you want to use it for a long time
LPTSTR lpszName = AfxGetThreadState()->m_szTempClassName;

// generate a synthetic name for this class
HINSTANCE hInst = AfxGetInstanceHandle();

View 11 Replies View Related

Visual C++ :: Reading NFC Device - Callback Function?

Jan 7, 2015

Is it possible to read NFC card reader in VC++/MFC. Is it possible to develop a callback function that will read the NFC device, and see once the card is inserted, it takes that value from the card and store it in a DB?

View 3 Replies View Related

C++ :: How To Get TinyXML In SDL Based Framework To Render Map

Jan 10, 2015

To the topic: I've been following "SDL game development" book by Shaun Mitchell and (besides the many others in the past) I've encountered a problem in one of the chapters.

I'm in "creating and displaying tile maps". The chapter uses tintxml to load data outside the code, which is used to create a "map screen".

The problem is that the program work perfect except for not loading and/or rendering this "screen".

I know this is too vague of an explanation, but I wouldn't know what else to say.

I'm leaving the link to the repository with all the code: [URL]...

View 12 Replies View Related

Visual C++ :: Resizing Controls And Text Content

Sep 11, 2013

I have a SDI application that uses a CFormView class to create a window and this window has 2 buttons and 2 edit boxes.

I can resize this window, like minimize and maximize, but the controls all stay at the same place.

I know that it's possible to move the controls based on window size.

But what i want to do is, as the window is expanded the controls and it's text content to grow proportionally and same when the window is shrinked.

Is that possible to do? i.e., increase/decrease size of controls and texts per window size.

View 2 Replies View Related

Visual C++ :: CDialogBar Moves Content (other Windows) In MDI Application When Docked At Left Side

Feb 19, 2013

I have a question concerning the CDialogBar (:CControlBar).

I have a MDI application with a dockable toolbox (CDialogBar).

The user is able/allowed to move the DialogBar and to dock it at the right or left side When I dock at the left side, the content of my mdi-application (so all other open windows) are moved right (so the dockable bar moves the windows).

If i dock at the right side, nothing changes.

How can I change the behaviour of the bar, that the windows inside the application keep the same position when I dock left ?

(Problem is, that my windows are aligned on the right side of the application). When I dock the bar on the left, the windows are getting moved in the not visible area.)

View 2 Replies View Related

C# :: The Name Does Not Exist In Current Context?

Feb 27, 2015

I am new to GUI programming, I am using mono winforms

using System.Windows.Forms;
using System.Drawing;
using System.IO;

[Code]...

I tried sw.WriteLine(this.to.Text); but that did not work

View 4 Replies View Related

C# :: Adding Program Into Context Menu

Feb 29, 2012

To add my program into the context menu (when the user right click on excel file). I used the following code:

Code:
public static bool AddContextMenuItem(string Extension, string MenuName, string MenuDescription, string MenuCommand)
{
bool ret = false;
RegistryKey rkey = Registry.ClassesRoot.OpenSubKey(Extension);

if (rkey != null)
{
string extstring = rkey.GetValue("").ToString();

[Code] .....

I used the following function to retrieve the excel file path has been rightclick choose to load the program:

Code:
public static void OpenExcelFileWithEasyForm(string filePath)
{
try
{
string excelFilePath = Path.Combine(Path.GetDirectoryName(filePath), string.Format("{0} (EasyForm){1}", Path.GetFileNameWithoutExtension(filePath), Path.GetExtension(filePath)));

[Code] .....

But I still do not load the excel file into my program by selecting the program from ContextMenu (right click on excel file and choose program). Although if select the path to excel file from the program, the data from excel file is loaded into the program.

I'm still missing something at function OpenExcelFileWithEasyForm(). How to complete this function to load the excel file into my program when selecting programs in ContextMenu.

View 1 Replies View Related

C# :: How To Get The Selected Context Menu Item

Sep 7, 2014

how to create a context menu but none of them discuss how to actually fetch the selected menu item?

if (e.Button == MouseButtons.Right)
{
ContextMenu m = new ContextMenu();
m.MenuItems.Add(new MenuItem("Font Size 8"));
m.MenuItems.Add(new MenuItem("Font Size 9"));
m.MenuItems.Add(new MenuItem("Font Size 10"));
m.Show(listBoxChecklist, new Point(e.X, e.Y));
//tempString = m.?????
}

View 3 Replies View Related

C# :: The Name (contentGrid) Does Not Exist In The Current Context

Sep 16, 2014

This is the code:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;

[code]....

I am using Visual Studio 2013.i was writing my first code for Windows in C#.I had got everything all right but Visual studio keeps showing me the problem that The name 'contentGrid' does not exist in the current context.I have tried Everything I could think of.I recentered the app to Windows 8.1.

View 2 Replies View Related

C++ :: Run From Context Menu With Selected Text From Browser

Jan 5, 2014

I'm trying to build an app, but i don't know which is the best language choice. For starters, the app should be able to:

1. run from context menu
2. when selecting some text from a web browser (ff, ie), that text is captured (preferably not in clipboard) and sent as argument to the program via context menu and the program starts executing...

Is this possible?

e.g. [URL] ....

View 2 Replies View Related

C# :: DataGridView - Context Menu To Show Up When User Right Clicks On Fifth Column

May 22, 2014

I have a datagridview with many columns. I want a context menu to show up when user right-clicks on the fifth column (column index = 4).

private void dgv_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
if (e.Button == MouseButtons.Right) {
DataGridView.HitTestInfo hit = dgv.HitTest(e.X, e.Y);
if (hit.ColumnIndex == 4) {
contextMenuStrip1.Show(Cursor.Position);
}
}
}

The problem is, the hit.ColumnIndex value is either 0, -1 or 1, no matter where I click. So the condition never met and the context menu never shows up. Why the values 0, -1 or 1?

View 3 Replies View Related

Visual C++ :: How To Transfer Particular Content From Notepad To Another Notepad

Jul 20, 2014

I need VC++ code,for copy the particular data from Notepad to another Notepad. Example, i have lots of data, i need to copy the particular content from Notepad to another Note pad.

Notepad 1:

<Debug: LogRLZ> arg Answer = windows //WINDOWS option will go to excel sheet
<Debug: LogRLZ> arg Answer = patio_doors //patio_doors option will go to excel sheet
<Debug: LogRLZ> arg Answer = entry_doors //entry_doors option will go to excel sheet

Notepad 2_expected Result:

windows
patio_doors
entry_doors

Same kind of datas are available in Notepad.

View 5 Replies View Related

C++ :: Look-up Mounting Point Of USB Device

Apr 15, 2013

I'm developing a short c++ program to scan all devices connected to the system through the USB connections.

I have used libusb to scan them and it really works but this library does not provide me with the mounting point, so I get a list of devices including manufacturer, serial number, etc but not the mounting point.

I have also used libudev library but it seems to happen something similar...

I need to get the mounting point for all USB devices connected to the board, you know: /dev/ttyUSB0 ....

View 1 Replies View Related

C/C++ :: Use Analog Device Through USB Interface

Sep 25, 2014

I am supposed to write a C program to send through USB interface to the analog device AD9914. Now I am doing the USB interface part where my computer has to detect the AD when it is plugged in and send the signals to it. I have to write the program to detect the device when it is plugged in. What kind of functions can I use? I know that the registry stores the device when it is plugged in. What functions are available to read?

View 2 Replies View Related

C/C++ :: Retrieve Data From USB Device

Jun 16, 2014

I am looking to retrieve data from a USB device, this device is a fingerprint scanner. Because I bought it online and wasn't reading carefully enough, drivers and other installation programs weren't included. Send it back? Nah . . .

I want to see if it is possible to retrieve data from this device. To be honest, I don't even know if it's possible, but I would love to give it a whack.

I looked into making INF files and things Microsoft has put out, but I honestly don't know where to start simply because I have absolutely no experience doing this. I have a program set up to organize the data and such, I just need to find a way to actually get it.

What should I research and look into? Are drivers necessary?

Here is a little more information :-)

I want to save data from a fingerprint scanner.I bought a fingerprint scanner, but nothing came with it (drivers, software, etc.). I decided to not return it and see what fun I could have.

I have no code written up yet (mainly because I don't know where to start). But I looked into the device a little...Microsoft recognizes it as a "Fingerprint Scanner" but is still considered unrecognized.I have the USB identifier (at work right now, don't have it on hand)...

Is it even possible to communicate with the device without the initial drivers.Do I really need drivers for the device, or can I communicate with it as it is now.If I do need drivers, where should I start?What should I look into to get communicating with the device?

View 6 Replies View Related

C Sharp :: How To Get A Device Name For A Given Ip Address

Aug 13, 2013

I need to get the network device name for the given ip address..

I tried with dns.getHostByaddress but it didn't worked..

View 1 Replies View Related

C++ :: Modelling Device In Embedded System?

Oct 13, 2013

What I want to do is abstract and model a device (more specifically in this case, an IMU) in an embedded system.

Now, there are a couple of gotchas:

- It is basically a framework, which means that it should work with any device, any platform and any bus.

- It is an embedded system, so power consumption and memory consumption must be reduced. It is not a PC.

- It cannot be too complex, because I fear that will just make people scrap it and rewrite it from scratch :P

- It should aim for as little code as possible to write the whole model, of course. Adding 100 lines of code for each register would be a bummer.

That said, I must also model the current system, which means that the current platform, the current bus (which is I2C) and the specific IMU model (I have a datasheet).
So the model I am thinking of currently is this:

First, I have a platform. It will know what bus a device is connected on and contains the buses (or specifically, the instances of the buses). It consists of a specific class for each platform and a base. Here are the two I have now:

Code:
namespace Sensors
{
template<typename Platform_t> class GPS;
}
namespace Platforms
{
class RaspberryPi: public PlatformBase

[Code]....

Currently I am making the assumption that all platforms will have an I2c bus and UART bus, but I'm not sure about that. We have only one platform ATM, though, so for now this holds. I'm guessing I might have to move it to the specific platforms later and get rid of PlatformBase.GetI2CBus is a problematic one related to registers, but I'll get back to that.

UART is simple to model since it's just a block read and write, so:

Code:
namespace Buses
{
class UART
{
public:
UART(const std::string& UARTPath): m_Open(false), m_PathToUART(UARTPath) {}

[Code]....

I'm probably going to handle all errors through exceptions. So if I can't open the UART bus, I'll throw an exception.

The I2C bus is a problem. I have a model which deals with it on a register-based level, but ideally I'd like to be able to model and use the devices on the I2C bus on a flag-based level (ie, I have names for each individual flag in the registers which I can read or write to directly instead of writing a hexadecimal value directly to each register).

Here is code:

Code:
namespace Buses {
template<unsigned int Id>
class I2CDevice {
public:
I2CDevice(I2C& Bus): m_Bus(Bus) {}
template<typename T>

[Code]....

So I2CDevice does some checks to see that the data to write to a register is either 8 or 16 bits. It does not check that the size to write matches the register's size, but another class does not.

The idea is also that it checks which device is currently active on the bus, and if it's not the current I2CDevice, then it simply selects that before attempting to read or write (the Open call).

This is not meant for multi-threaded environments. Yet, anyway.

The Impl2::Read/Write just dispatches the call so it calls the correct function for writing and reading the correct size, depending on the size of the data.

This is all well and good, but I2C works with registers, so of course I want a class to model a register which I can read and write to directly. It must tie into the bus class since the bus class is the one that abstracts reads and writes on the bus.

The register class looks like:

Code:
template<unsigned int Bits, unsigned int RegisterId, typename Bus_t>
class Register {
public:
typedef typename Impl::RegisterBase<Bits>::Storage_t Storage_t;
static_assert(!std::is_same<Bus_t, Buses::UART>::value, "Cannot read and write registers on the UART bus.");
static_assert(Bits == 8 || Bits == 16 || Bits == 32 || Bits == 64, "Number of bits must be 8, 16, 32 or 64.");
auto Write(Storage_t Data) -> void

[Code]....

I think this explains itself, except for the Regs struct, which is an experiment by me to enable myself to access registers via Regs.Config, etc.

What is missing is the ability to access and read/write the individual bits inside the registers. I am thinking a two-way access, where you can write to individual bits, but must call .Write() to commit the write to the register for efficiency.

I haven't actually written this. I don't know a good way ATM. I don't want to add a lot of variables and a write function because that would use 1 byte for every bit which is unacceptable.

I don't want to add a lot of code to make it work, either. A good get/set class would be nice, but I can't see that working. The register must store all state and any subsequent classes must not store any state or overhead will increase.

Finally, yes, I know a lot is incomplete and untested. It probably won't even compile. But that is for later. First is finishing the model.

It would be nice if things such as the platform and buses could be made static because there will only be one instance at any time, and that would save overhead if I don't have to store objects or references to them, but I haven't figured out how to achieve this.

View 13 Replies View Related

C++ :: Execution Of Certain Commands - Setting Device Time

Sep 10, 2013

I got a assignment in which i have to write codes for execution of certain commands.

One of the command is set_time. if user enters set_time 12:12:12

The time should get reset to 12:12:12 no matter what it is now.

View 7 Replies View Related

C++ :: Using Clear Device And Sleep Functions In Graphics

Dec 14, 2014

I have a college project which is a car racing game using C++ and the old-school graphics library BGI. After I draw the map and placed the objects(Car,obstacles,road's borders etc..)I added Sleep(); function to the function named Obstacles(); but the problem is, I can't move the car with the right&left arrows.a

Another problem,If I added a cleardevice(); command all objects disappears only the obstacles function keeps working. the Code is here:

char c;
do{
c = (char)getch();
if (c == KEY_LEFT) {
x = x - 10, x1 = x1 - 10;
} if (c == KEY_RIGHT) {
x = x + 10, x1 = x1 + 10;

[code].....

note: this is not the whole code, it's only a small portion of it, not a debugging question only need a hint how to fix it.

View 3 Replies View Related

C :: Program To Read Data From USB Device Connected To System

Sep 26, 2013

I am trying to fetch data from the USB device(say pendrive) connected to the USB port of a system. I have attached code.c file which I have wriiten for the same purpose, please find it. Here I am able to open the device file and read some random raw data which is in the log.txt file (also attached to this mail). But I want it to fetch data like minicom/teraterm does.

What methods and libraries I can use to do it successfully and how can it be done.

View 2 Replies View Related

C++ :: Read 100 Elements From Standard Input Device And Store Them In Array

Feb 19, 2014

Write code to do the following:

1) declare a variable ptr as a pointer to int and initialize it to NULL
2) dynamically allocate memory for an array of 100 elements
3) read 100 elements from the standard input device and store them in the array.

This is what I have so far, I'd like to know if its ok or if something is wrong.

int *ptr = NULL;
ptr = new int[100];
cin >> dataPtr [arr];

View 2 Replies View Related

C++ :: Memory Allocation With Sprintf And Strcat For Reading 1-Wire Device

Mar 9, 2012

I'm using a uC to read the device ID from a One Wire device. I'm trying to have the ID read every second and output to over a USART serial stream for debugging, however I'm having a number of problems getting this to work correctly and I think it has to do with my misunderstanding of memory allocation in this case.

The problem is that when I upload the binary to the uC, it gets the device ID correctly the first time, and from thereafter the program is unstable and starts returning garbage (1st screenshot).

Ideally everything inside of the while loop would be inside of its own function, however I have had nothing but trouble doing that. In fact, when I put that all into it's own function that returns void and takes BUSES as an input, the correct data comes out the first and therefore it somehow exits the "while" loop and never gets back in (2nd screenshot). Another thing I noticed is that when I put the variable declaration outside of the while loop in the code below, I get the same behavior.

I haven't include the code for OWI_DetectPresence and OWI_SendByte ... I've hooked up an oscilloscope and have visually confirmed they are working correctly. Once the OWI_ROM_READ byte is sent over the bus the slave responds with it's device ID. I feel like my issue here is memory allocation and not hardware.

how to fix the issue with the output to USART and how to make this into a function that returns the string of the hex ID?

Code:

int main(void) {
unsigned char OWI_on_bus = FALSE;
// initialize UART for debugging
Init_USART();

[Code].....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved