Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all 3021 articles
Browse latest View live

modify window component properties on runtime

$
0
0
Hi I want modify window component properties on runtime from other program Like this https://sites.google.com/site/partycaption/fonts regards

C++ Files.

$
0
0
Can someone tell me why the statement *if( read.eof() )* is not executed? I'm reading the whole file so this stream should reach the end of file, yet i can't understand why the statement is not running. Code: --------- #include #include #include int main(){ std::ifstream read("Source.cpp", std::ios::binary | std::ios::ate); std::ofstream write("C:\\Users\\zervos\\Desktop\\s.cpp", std::ios::binary); std::streampos size; char *bytes; if (read.is_open() && write.is_open()) { size = read.tellg(); bytes = new char[size]; read.seekg(0, std::ios::beg); read.read(bytes, size); if ( read.eof() ) std::cout << "eof" << std::endl; read.close(); write.write(bytes, size); delete[] bytes; write.close(); } else std::cout << "Files error" << std::endl; system("pause"); return 0; } ---------

Why an application is no longer "themable" if I move out the uxtheme.dll file?

$
0
0
I created a themed application and I put the uxtheme.dll inside it, then there is no "theming" effect... But when I remove that local file, then keep using the syswow64 one, it works very well. How come uxtheme.dll must be located in syswow64? How come I can't have every standalone shell program to theme itself? Thanks Jack

Database connection confusion

$
0
0
Hi, ALL, On the page (https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlgetinfo-function) it says: ---Quote--- SQL_USER_NAME(ODBC 1.0) A character string with the name used in a particular database, which can be different from the login name. ---End Quote--- However, this (https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqltables-function) page uses this in the example to (presumably) retrieve the user connected to the DB. Does the sample implies that I can use such technique? Or this is merely a sample? If its the latter - what condition would trigger an inconsistency the first page is referencing? Or this is for ODBC v1/v2 and in version 3 this works consistently across different DB vendors? I'm actually looking for a username which has a current connection (or the one that currently connected to the DB). Thank you.

How is it possible to theme the start button and start menu etc?

$
0
0
https://www.codeproject.com/Articles/7247/Themed-Windows-XP-style-Explorer-Bar I have created a hacked version of xp explorer. Does anyone know how to theme the start button, taskbar and the start menu? This project supports button, combo boxes, listboxes, textboxes, etc I think the start menu and start button has a special class names for them. How do I theme them using this library.... Thanks Jack

Simulate cursor ( mouse ) movement

$
0
0
Code: --------- int x = 100; int y = 100; SetCursorPos(x,y); Sleep(2000); SetCursorPos(x+100,y+200); --------- This code sets cursot to one dot, after 2 seconds to another dot. However cursor just "teleporting". And I want to make cursor to "walk" from one dot to another, not just "teleport". Its kinda like demonstration. Cursor should stay visible ( and it is ), i simply want to make 'travelling route'.

[RESOLVED] code generation

$
0
0
hello there I need help with my code plz

[RESOLVED] c++ dictionary

$
0
0
I have a total new concept I want to use . I never used this before . I want to add a dictionary to my c++ program I want it to be able to include it in my program to use it to search for words in 2d arrays ( I heard about 8 direction search ) . can you help me ?? thx alot

Ribbon on a child frame, possible?

$
0
0
Hi! I´m migrating an aplication from old style Windows to new ones with ribbons. This aplication is a MDI model and every child window has his own toolbar. Would be cool if I could change these toolbars on the child windows to ribbons, but I have serched a lot and haven´t find a way to do that. Is that possible? If so please give-me some hints of how to do that. Thank you

Need help drawing rectangle on Windows desktop...

$
0
0
I have created an application that copies a specified rectangle from the Windows desktop and creates a video stream from it. I have the basic functionality working. I need a means of drawing a re-sizable rectangle on the Windows desktop, that has a transparent background (transparent client area within the rectangle). I was looking to use some code I found that was supposed to create a Window frame that had no title bar, and a transparent client area, and just get the RECT of the client area (as a means to specify the desktop area that would be copied to the video stream). Unfortunately, with Windows 10 the window boarder size is 0, so if the window client area (background) is transparent, then the user can not see the boarder at all. Anyone know of any example code for drawing a rectangle on the Windows desktop that has a transparent area in the center? Even better would be code that allows for the rectangle to be resized with the mouse. Thanks for any help you can offer!

How do I put a COM-aware control onto a form (.rc file) or programatically?

$
0
0
How do I make the controls in my form located in my .rc file aware of the theme wrapper? It exposes theme related functionality I want to either put the controls coming from Advanced Theme wrapper programmatically Or All the controls to be aware of the "hooking" library??? Thanks Jack Code: --------- #include #include #include "resource.h" #include "commctrl.h" #import "E:\Projects\Personals\Shell\XP Theme\Advanced Theme Wrapper\Advanced Theme Wrapper\Demo\bin\Release\Devcorp.Controls.VisualStyles.Sample.tlb" no_namespace #import "E:\Projects\Personals\Shell\XP Theme\Advanced Theme Wrapper\Advanced Theme Wrapper\lib\bin\Release\Devcorp.Controls.VisualStyles.tlb" no_namespace int dialogID = IDD_DIALOG1; INT_PTR CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { IVisualStyleSwitchable* button = NULL; HRESULT hr = E_FAIL; switch(msg) { case WM_INITDIALOG: hr = CoCreateInstance(__uuidof(CustomButton),NULL,CLSCTX_INPROC_SERVER,__uuidof(IVisualStyleSwitchable),(void**)&button); break; case WM_DESTROY: case WM_CLOSE: PostQuitMessage(0); break; } return DefWindowProc(hwnd, msg, wparam, lparam); } int main() { CoInitialize(NULL); //InitCommonControls(); // put the button on the form HINSTANCE hInstance = GetModuleHandle(NULL); DialogBoxParam ( hInstance, MAKEINTRESOURCE(dialogID), nullptr, DialogProc, 0 ); //CoUninitialize(); return 0; } ---------

SQLBindCol() for the char column

$
0
0
Hi, ALL,
I have a problem.

I'm trying to connect to MS SQL Server and perform a query. The table I am trying to access has a "char(1)" column.

This is the code I'm using:

Code:

SQLWCHAR dataFontItalic[2];
SQLLEN cbDataFontItalic = SQL_NTS;
ret = SQLBindCol( stmt_tableProp, 6, SQL_C_BIT, &dataFontItalic, 2, &cbDataFontItalic );

When I call SQLFetch() it produces a following error from SQLGetDiagRec():

Quote:

Invalid character value for cast specification.
Changing the type of dataFontItalic to SQLCHAR does not help. Passing '1' to SQLBindCol() also does not help.

Could someone please help?

Thank you.

Problem with utf-8 on Linux

$
0
0
I am looking for help on how to transfer cpp file with international characters from MSVC++ to Ubuntu.. such as: const string sTest = "ŠČÊĐ". To save that on MS Visual studio as UTF-8 or codepage 1250... encoding? What command on linux will recheck file: I have tried with: file -bi mzfile: text/x-c; charset=utf-8 It seems ok, but it still would not recognise the international characters.. Why? Why mime format?

Reading Binary Files in C++

$
0
0
I am having trouble taking values from byte locations in my file. The code below works for certain locations where you have to read 2-bytes, it does not seem to work with 4-bytes however. I believe there must be something wrong with my interpretation of how to read(char*, int) function reads binary data. What I'm looking for is the ability to read say 4 bytes of binary data, and store the decimal value/char value of each byte of data in an index of the array. That is my understanding of how the read function works. For one section of 4-byte code I should get an overall value of 1500, but instead I get 101 in the second index(1 starting from 0) which is incorrect. The other indices are zero using variable watch. I know should someone get an array that has 220 in the first index and 5 in the second index. After bit shifting this will evaluate to 1500. Any insight as to why my read function is not assigning the values to my array that I need? Two other programs written by other people, (one in pascal one with no source code) read 1500 for this specific byte location so something must be off in my implementation of the read function. Code: --------- unsigned char buf[4]; //{220, 5, 0, 0 }; ->values that my read function should be assigning uint64_t buf1[4]; uint64_t value = readBufferLittleEndian(buf, &file, buf1); cout << value; system("PAUSE"); return 0; } uint64_t readBufferLittleEndian(unsigned char buf[], std::ifstream *file, uint64_t buf1[]) { file->seekg(3213); file->read((char*) buf, 4); for (int index = 0; index < 4; index++) { buf1[index] = static_cast(buf[index]); } return ((uint64_t)buf1[3] << 24 | (uint64_t)buf1[2] << 16 |(uint64_t)buf1[1] << 8 | (uint64_t)buf1[0]); } ---------

Creating a VERTICAL Histogram or Bar Graph

$
0
0
I am writing a C++ program that inputs a file of 3000 resistor files and writes them to a vector. I have already done the vast majority of the program, and now I am just trying to display a VERTICAL HISTOGRAM or Bar Graph. There are 3 different types of resistors, R100, R1000, R10000. I am working the R100 graph right now. The actual values aren't exactly equal to their type, but most are close. The Bar Graph is to display the counts of a range of values from 90 - 110. I have written a function already that has counted each bin of the graph. There are 11 bins, or range values: 90, 92, 94, 96, 98, 100, 102, 104, 106, 108 and 110. I want the VERTICAL HISTOGRAM or Bar Graph to display each bin value, 90 - 110 etc, at the bottom of the graph and then display the counts of each bin using a * symbol. I was planning for each * symbol to represent a count of 100, but if there are less than 100, I still want to place at least one * so I don't have any empty bins on the graph. For example, the count of the first bin is 25, there should be one * there. I want the graph to have 10 rows, so there would be a cap, any bin with a count of 1000 or higher would have 10 vertical stars, or *. I have written the counts to an array of 11 elements, each element represents a count corresponding to its bin. I named the array "counts" and gave it an integer datatype. So the array data with explanations for the graph and each of its bins are as follows: ** These are the Actual Counts that Were Returned By My Code: ** Code: --------- counts[0] = 25 // This column on the Bar Graph should have one * symbol, as it is less than 100, and represents resistors with a value of 90 or less counts[1] = 1027 // This column on the Bar Graph should have 10 vertical * symbols, as a count of 1000 is the cap, and represents resistors with a value greater than 90 and <= 92 counts[2] = 917 // This column on the Bar Graph should have 10 vertical * symbols, as it is greater than 900, and represents resistors with a value greater than 92 and <= 94 counts[3] = 777 // This column on the Bar Graph should have 8 vertical * symbols, as it is greater than 700, and represents resistors with a value greater than 94 and <= 96 counts[4] = 641 // This column on the Bar Graph should have 7 vertical * symbols, as it is greater than 600, and represents resistors with a value greater than 96 and <= 98 counts[5] = 535 // This column on the Bar Graph should have 6 vertical * symbols, as it is greater than 500, and represents resistors with a value greater than 98 and <= 100 counts[6] = 436 // This column on the Bar Graph should have 5 vertical * symbols, as it is greater than 400, and represents resistors with a value greater than 100 and <= 102 counts[7] = 323 // This column on the Bar Graph should have 4 vertical * symbols, as it is greater than 300, and represents resistors with a value greater than 102 and <= 104 counts[8] = 204 // This column on the Bar Graph should have 3 vertical * symbols, as it is greater than 200, and represents resistors with a value greater than 104 and <= 106 counts[9] = 87 // This column on the Bar Graph should have one * symbol and , as it is less than 100, and represents resistors with a value greater than 106 and <= 108 counts[10] = 3 // This column on the Bar Graph should have one * symbol and , as it is less than 100, and represents resistors with a value greater than 108 --------- Again, I am looking to display a VERTICAL HISTOGRAM, or Bar Graph using the data from above. Please Help Me!!

How to fix this warning?

$
0
0
Hi, guys,
I have following code:

Code:

int bufferSize = 1024;
SQLSMALLINT lenUsed;
for( int i = 0; i < numCols; i++ )
{
    autoincrement = 0;
    columnNames[i] = new SQLWCHAR[sizeof( SQLWCHAR ) * SQL_MAX_COLUMN_NAME_LEN + 1];
    ret = SQLColAttribute( stmt_colattr, (SQLUSMALLINT) i + 1, SQL_DESC_LABEL, columnNames[i], bufferSize, &lenUsed, NULL );
}

Compiling this with MSVC 2010, I'm getting:

Quote:

warning C4244: 'argument' : conversion from 'int' to 'SQLSMALLINT', possible loss of data
on the SQLColAttribute() call.

How do I fix the warning?

Thank you.

Function sequence error

$
0
0
Hi, My application connects to MS SQL Server performs some queries and then disconnects and finishes. Upon disconnecting I'm releasing all handles that I allocated on connection. Unfortunately when releasing the very last one (environment handle) I'm getting "Function sequence error". Now my question is - Since it is MS SQL Server I'm allocating many different connection and statement handles and then release them afterwards. Is there a way for me to get which function didn't close the connection or release HDBC handle? If there is none - what would you recommend for the debugging this issue? Moving thru the code would be hard as it is a big code (even though I wrote all of it) and I'm afraid I may just inadvertently skip the error. Thank you for any pointers.

stone division code

$
0
0
Consider the following game: There are two players, First and Second, sitting in front of a pile of stones. First always plays first. There is a set, , of distinct integers defined as . The players move in alternating turns. During each turn, a player chooses some and splits one of the piles into exactly smaller piles of equal size. If no exists that will split one of the available piles into exactly equal smaller piles, the player loses. Both players always play optimally. Given , , and the contents of , find and print the winner of the game. If First wins, print First; otherwise, print Second. Input Format The first line contains two space-separated integers describing the respective values of (the size of the initial pile) and (the size of the set). The second line contains distinct space-separated integers describing the respective values of . Constraints Output Format Print First if the First player wins the game; otherwise, print Second. Sample Input 0 15 3 5 2 3 Sample Output 0 Second Explanation 0 The initial pile has stones, and . During First's initial turn, they have two options: Split the initial pile into equal piles, which forces them to lose after the following sequence of turns: stone-division.png Split the initial pile into equal piles, which forces them to lose after the following sequence of turns: stone-division-2.png Because First never has any possible move that puts them on the path to winning, we print Second as our answer. Submissions: 214 Max Score: 50 Difficulty: Hard Rate This Challenge: More my code is this but it not pass all the test cases so i need answer for this Code: --------- #include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n,m; int flag=0; cin>>n; cin>>m; int arr[m]; for(int i=0;i>arr[i]; } for(int i=0;i

Query fails with C++ ODBC - works with Management Studio

$
0
0
Hi, ALL, I'm trying to execute a following query (using MSBV 2010, ODBC, SQL Server 2008): Code: --------- L"SELECT rtrim(abt_tnam), abt_tid, rtrim(abt_ownr), abd_fhgt, abd_fwgt, abd_fitl, abd_funl, abd_fchr, abd_fptc, rtrim(abd_ffce), abh_fhgt, abh_fwgt, abh_fitl, abh_funl, abh_fchr, abh_fptc, rtrim(abh_ffce), abl_fhgt, abl_fwgt, abl_fitl, abl_funl, abl_fchr, abl_fptc, rtrim(abl_ffce), rtrim(abt_cmnt) FROM abcattbl WHERE \"abt_tnam\" = ? AND \"abt_ownr\" = ?;"; --------- When executed inside SQL Server Management Studio there is no issue. The query is executing fine and I am getting the results. However when executing thru the C++ code, the call to SQLExecute() fails. The error is: ---Quote--- String data, right truncation ---End Quote--- and the error code is 22001. If I Remove rtrim() calls, everything works fine. Unfortunately this is not an option as those fields are char() and not varchar(). Moreover this same query works fine on PostgreSQL driver on OSX with iODBC DM. Trying to wrap the parameters with rtrim() also doesn't help. I'm getting exactly the same error. Below is the table structure: Code: --------- CREATE TABLE \"abcattbl\"(abt_tnam char(129) NOT NULL, abt_tid integer, abt_ownr char(129) NOT NULL, abd_fhgt smallint, abd_fwgt smallint, abd_fitl char(1), abd_funl char(1), abd_fchr smallint, abd_fptc smallint, abd_ffce char(18), abh_fhgt smallint, abh_fwgt smallint, abh_fitl char(1), abh_funl char(1), abh_fchr smallint, abh_fptc smallint, abh_ffce char(18), abl_fhgt smallint, abl_fwgt smallint, abl_fitl char(1), abl_funl char(1), abl_fchr smallint, abl_fptc smallint, abl_ffce char(18), abt_cmnt char(254) PRIMARY KEY( abt_tnam, abt_ownr )); --------- Does anybody have an idea what is going on and how do I fix this? TIA!

Antivirus app

$
0
0
Hi all of you. I intend to develop an light antivirus application, and I have some questions first: 1. Is there somewhere an virus signature database, available for development ? 1. How can I test an file if is virused or not, without virus signature database ? I have checked Clamav library, which is free, but it is for Linux. and using this library for Windows are not a good option [the virus signature database are filled with Linux viruses, not for Windows]. I will appreciate any advice/hint regarding my issues ! Thank you.
Viewing all 3021 articles
Browse latest View live