|
Vaclav_ wrote: I am finding out this setw does not always work More likely, you are finding there are bugs in your code.
|
|
|
|
|
|
That is little out of my league, but when I have a break I'll give it a try.
|
|
|
|
|
how to use LoadString in c++
|
|
|
|
|
The Windows API LoadString() expects a buffer, not a C++ string. The easiest way to use it would be something like:
std::wstring GetStringW(HINSTANCE hinst, UINT id)
{
std::vector<wchar_t> buffer(256);
::LoadStringW(hinst, id, buffer.data(), static_cast<int>(buffer.size()));
return &buffer[0];
}
which would convert the buffer into a std::wstring.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
|
Hi
I have a bitmap file of a red bullet Originally I tried to display it using RichEdit Ole Interface I copied the code modified it somewhat from
the "Q220844: HOWTO: Insert a Bitmap Into RTF Document Using RichEdit Control" I was able to display it however it didn't fit quite right
So I decided to go with a native Win32 and display on Static control adjacent to the rich edit
Thing is where the OleCreateFromFile worked the LoadImage API fails GetLastError return a zero as well using File Explorer I can see the red bullet
Thnaks
|
|
|
|
|
You aren't trying to load a jpg, gif or png are you .. loadimage does not support those it is strictly BMP and PCX.
If you need those just use IPic and for that all you need is #include <olectl.h>
In vino veritas
|
|
|
|
|
Are you referring to OLeLoadPicturefile BTW As I mentioned to Richard when I used the code example in the following article Quote: Q220844: HOWTO: Insert a Bitmap Into RTF Document Using RichEdit Control"
Even though I had a 1 in the first param of the SetSel the Red bullet didn't align itself right next the left border of the dialog box
In file explorer the image looked fine.
Opening up the image in Paintbrush I see a white rectangular border around the red bullet maybe that was part of the problem
I loaded the image by doing a google search is if this is the problem is there a way from get this image (I am trying to get something like the visual studio Breakpoint)
Thanks
|
|
|
|
|
So much confusion and misunderstandings to know where to start.
Lets start with SetSel misunderstanding which starts at 0 NOT 1 it is a zero-based index.
Very important is the file type you didn't say what the file was look at the last 3 letters of the filename is it BMP, GIF, JPG or PNG?
Yes if you have a white border the white border will be on the image UNLESS it is a transparent image which needs a special header and depends on file format (so again we need the file format).
You said you change the code over to LoadImage and I warned you that you can only load files that are of BMP and PCX type. That is files that end with those 3 letters and have a proper matching header. If you try to load a wrong type it does pretty much what you describe returns NULL with a GetLastError of 0 because it can find the file but it's just junk it can't understand.
So can we at least get a filetype to start with so we know what we are dealing with, so 3 letter filename extension please. If you can't see them on windows go up to view settings and tick the box that says file name extensions.
In vino veritas
|
|
|
|
|
I understand that LoadImage wont work, Let me ask the following if I use LineIndex(-1) then I am returned the char index on the line and its I ASSUME it is the first char index in that line that has the caret
Afterwards if I do GetCharPos using that value I get the x,y coordinates in pixels of that char so I would like to place my bullet there and x = 1 that it should lie all the way to the left of the rich edit control and yet its off (about 1/8 of inch) my only guess is when I display the bullet in paintbrush there is white rectangle around it
and that is what is pushing it off. what do you think
if this true would you know how I would go about getting a red bullet bmp/png like the breakpoint in Visual studio Debugger
Thanks
|
|
|
|
|
Well techinically it is x = 0 but there is nothing stopping you simply entering a negative x co-ordinate of a few pixels to allow for your white border.
The richedit like all windows knows how to clip
In vino veritas
|
|
|
|
|
I expect your code is wrong. But since you have not shown us what code you are using it is impossible to say more.
|
|
|
|
|
|
You will need to provide much more information before anyone can help you with this. You say that it shows junk values; what are those values and why are they junk? What is the code that produces them, and what input data is used to create the values in the first place?
|
|
|
|
|
Richard
Here is the statement
HANDLE hBmp = (HBITMAP) LoadImage(AfxGetInstanceHandle(), _TEXT("C:\\DriveRichEdit\\DriveRichEdit\\DriveRichEdit\\res\\bullet_red.png"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
As leon mentioned LoadImage may not work with .png files
I am trying to emulate Visual Studio Debugger Breakpoint, when I used the RichEdit OLE interface and look at the SetSel parameters I see the first value (The x value as 1) however is stands away from right edge of the Parent Dialog frame (maybe by 1/8 of inch).
Looking at the image in file explorer it looks just fine but when I am open the image in paintbrush I can see a rectangular white border around it and maybe that is part of the problem. If that is a problem would you have any suggestion for me how to get an image ie. red bullet, I picked this one up by doing a google search thanks
|
|
|
|
|
Most likely your code relies on a variable being zero or a BOOL false which you haven't specifically set to zero/false.
Look at all your variables which require a preset zero value and make sure you set them.
When you run in debug mode because it is going to display things it first zeros all variables, that does not happen when you run in normal mode.
This for example will print 0 in debug F5 mode but could print anything in normal ctrl-F5 mode because i is not set
int i;
printf("i = %i\n", i);
In vino veritas
|
|
|
|
|
Are you sure variables are not initialized for a debug build when run with ctrl-F5? ctrl-F5 only implies that the code will be run without attaching the VisualStudio debugger. It does not mean the code will be run in release mode - there may not even be a release mode executable to run.
I do know that you can run a release build with F5, and when you inspect an uninitialized variable, it will most likely not show a null value, just as you described - but that does not depend on whether or not you attach a debugger.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
You are getting build configuration mode as in "debug" and "release" mode come in that isn't relevant.
The act of connecting a debugger does it's thing which is connect to the memory space, function and variables it doesn't give a rats about build mode.
From a memory point the key thing it does is drop it's own heap manager which has been forever but started to be improved in VS2014 and now it connects to that whole memory display gadget that seems to get slower and slower each release.
C++ Debugging Improvements in Visual Studio "14" | C++ Team Blog[^]
That means whenever you run the debugger the heap is different to normal unless you go thru the hijinx to turn it off which used to be as simple as _NO_DEBUG_HEAP = 1 but like everything it has gotten successively harder.
In vino veritas
|
|
|
|
|
I'm working on a C++ native code graphics application using DirectX9. I use the latest version of Visual Studio Community 2019. When working in the IDE the application crashes from time to time with a message like
"Exception thrown at 0x00007FF9762975D6 (nvd3dumx.dll) in NNetSimu.exe: 0xC0000005: Access violation reading location 0x000001B388FE1A3E."
So far I could not reproduce the error, it happens once in while. The strange thing is: If I call the application directly, it runs very stable, the problem occurs only in the IDE.
The crash happens always during the end of a frame, typically during swapChain->Present. My code:
void D3D_driver::EndFrame( HWND const hwnd )
{
HRESULT hres;
hres = m_d3d_device->EndScene(); assert(hres == D3D_OK);
hres = m_d3d_swapChain->Present( nullptr, nullptr, hwnd, nullptr, 0 ); assert(hres == D3D_OK);
m_id3dx_font->Release();
}
I could live with the situation, the app runs smoothly without IDE, but it is annoying during development.
Any ideas how I could further investigate the problem?
modified 13-Dec-19 19:32pm.
|
|
|
|
|
Since the problem appears to be within Microsoft's library it would be best to report it to them.
|
|
|
|
|
Hi
Can bullet used as numbering in paraformat/ CricheditCtrl::SetPartaFormat be colored
I am trying to create an image such as the breakpoint bullet in Visual Studio debugger
thanks
|
|
|
|
|
Does the SetParaFormat method contain an option to set the colour, or does it use the default of the current font?
|
|
|
|
|
Thanks wasn't sure if bullets could be colored I'll use the the SetSelectionCharFormat member crTextColor of charformat to color the text
thanks
|
|
|
|
|
Ripping my hair out with this one. I develop for some Windows Embedded Compact 7 products where we use VS2008 with add-on SDKs. All service packs applied, I've been using the same setup for the A week or so ago, I did a code merge between two branches and broke on of my applications. In trying to debug the issue, I discovered that no matter where I placed breakpoints, they would immediately go clear with a warning. Mousing over shows the message in the title bar. In doing my debug of the debugger work, I have:
- full clean rebuild;
- delete all PDB, suo and ncb files;
- create a new application;
Nothing corrects the issue. In fact, the last item is a simple dummy hello world dialog app, and it has the same breakpoint issue. So something bad has happened to the installation I'm guessing. In reading all the SO discussions, it appears that most people solve this by making random changes until it starts working.
Does anyone have a definitive explanation or solution for this behavior?
Thanks
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|